print_msg needs to be synched

Edgar
2011-02-10
2013-04-25
  • Edgar
    Edgar
    2011-02-10

    Hi,

    playing with some different block/cache sizes I got an error #1784 = ERROR_INVALID_USER_BUFFER
    in serve (WriteFile wincall_file / VC9). Error produces character output while the main thread writes to stdout resulting in character salad.

    Regards
    Edgar

     
  • I assume that you only complain about the character salad, not the error message itself.

    Is the message of the main program related to the failure?
    This happens on Windows only, Linux synchronizes line-wise anyway.
    How would you synchronize with an arbitrary stdout output by the main program.

    Johannes

     
  • I'm not complaining about ERROR_INVALID_USER_BUFFER (buffers got invalidated before written).
    The message from the main thread is not related to the failure. It displays some diagnostics.
    At the first sight I would use a thread mutex in verbose.cpp:print_msg, since I am using STXXL_MSG,…
    for diagnostic output. A more sophisticated way could be a synched streambuf for the std::cout.

    Edgar

     
  • Sorry for complaining.
    The character salad  seems to be a result of my buffer mismanagement.
    std::basic_ostream<> comes with synch support (vc9).
    Nevertheless Windows provides no line-wise synchronization.

    cout << "…\n"; // ok
    cout << "…" << std::endl; // not synched

    Edgar