Thread: Quick Problem Check

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Quote Originally Posted by hamster_nz View Post
    You want to close the pipes in the works when done, so the reader gets a POLLHUP to react to.

    This is also broken:
    Code:
                struct worker_msg *worker_msg = NULL;
                ssize_t bytes;
                 
                bytes = rdpipe(
                    mm_pipes[PIPE_RD], &worker_msg, sizeof(struct worker_msg) );
    The point of the pipes is to keep them open until the worker owning them dies, originally I was gonna have all the workers talk to each other via the pipes, I've since realised that was a partially bad idea as it would lead to faulty code all over the place, I now have the main thread acting as a middle man where every worker gets a reference to the main thread's pipes and a reference to pipes created for the main thread to talk to them, the main thread is now in charge of memory allocations too so there'll be no need for the risk of a memory managing worker suddenly dieing, at least if the main thread dies then all threads die with it. The main thread also handles the closer of pipes and other worker related stuff linked by the worker structure, although any internal stuff is still the responsibility of the worker itself to cleanup if it needs anything more than a deallocate (which again the main thread can act as a garbage handler for)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick check for potential problems
    By awsdert in forum C Programming
    Replies: 28
    Last Post: 08-13-2020, 07:55 AM
  2. Quick program check
    By Nik635 in forum C Programming
    Replies: 1
    Last Post: 09-17-2015, 08:20 AM
  3. Quick check
    By SofaWolf in forum C Programming
    Replies: 6
    Last Post: 06-26-2012, 12:53 PM
  4. Need a quick check
    By Aliaks in forum C++ Programming
    Replies: 7
    Last Post: 06-05-2009, 04:57 AM
  5. Quick input check question
    By Jozrael in forum C++ Programming
    Replies: 3
    Last Post: 01-20-2009, 07:23 AM

Tags for this Thread