[Pianod] wsgw hanging on RasPi; deadlock?

Peter Li chinasaurli at gmail.com
Mon Feb 25 15:09:36 PST 2013


Okay, I fixed a couple of putative bugs.  The clientbuf/serverbuf one 
seemed to be the cause of the hanging.  I guess on my desktop (and your 
setup) the client_to_server thread gets started early enough that it 
wasn't causing a problem, but on the RasPi the server_to_client thread 
instructions were getting moved in front so that the bug was unmasked.

In the course of tracking this down, I also tried changing the mutex 
setup to a simple pthread_join(client_id); pthread_join(server_id); and 
that seemed to work fine.  Not including the patches but I can send if 
you want; it seems like a nicer way to handle things?

Also now that the clientbuf/serverbuf are seemingly disentangled from 
each others' threads, would probably make sense to create and free those 
buffers from within their own threads?

I'm a little bit guessing here, but since it seems to work with the 
patch below I think the above is correct.
P


    Index: wsgw.c
    ===================================================================
    --- wsgw.c    (revision 10)
    +++ wsgw.c    (working copy)
    @@ -206,7 +206,7 @@
          ssize_t header_size = 0;
          char *header_line[100];
          int lines = 0;
    -    char valid_request = true;
    +    bool valid_request = true;
          bool server_ok = true;
          REQUEST request;
          memset (&request, 0, sizeof (request));
    Index: bridge.c
    ===================================================================
    --- bridge.c    (revision 10)
    +++ bridge.c    (working copy)
    @@ -498,7 +498,7 @@
          ARGUMENTS *args = (ARGUMENTS *) arguments;
          unsigned int bufsize = 4096;
          args->serverbuf = malloc (bufsize);
    -    bool active = (args->clientbuf != NULL);
    +    bool active = (args->serverbuf != NULL);

          /* Read from server a bit into the buffer, so we can add the
    header before sending */
          char *buffer = args->serverbuf + WS_HEADER_MAXIMUM;
    @@ -553,7 +553,7 @@
          ARGUMENTS *args = (ARGUMENTS *) arguments;
          unsigned int bufsize = 4096;
          args->serverbuf = malloc (bufsize);
    -    bool active = (args->clientbuf != NULL);
    +    bool active = (args->serverbuf != NULL);

          /* Read from server a bit into the buffer, so we can add the
    header before sending */
          char *buffer = args->serverbuf + WS_HEADER_MAXIMUM;




On 02/25/2013 01:46 PM, Peter Li wrote:
> Hi Perette,
>
> As I mentioned before, wsgw and the webclient work nicely when wsgw 
> runs on my desktop, but it seems to hang when running on either of my 
> RasPis.  I looked into it a bit more and it appears that the problem 
> is because run_bridge is failing to get bridge_client_to_server open.  
> My guess is that these is a deadlock issue with the shared 
> completion_mutex?
>
> Will look into it more, but I don't have much experience with pthreads 
> so thought I would run it by you.
> P

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deviousfish.com/pipermail/pianod-deviousfish.com/attachments/20130225/430ca29e/attachment-0003.htm>


More information about the Pianod mailing list