Przemek,

Il 07/03/2009 19.51, [email protected] ha scritto:
2009-03-07 19:56 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
  * harbour/contrib/examples/uhttpd/uhttpd.prg
    ! fixed close procedure, s_aRunningThreads and s_aServiceThreads
      where not protected at all in the moment when these variables
      variables where used inside aeval() and other threads were
      resizing them removing their pointers. In short word it was
      in practice impossible to cleanly close uhttpd server without
      GPF, deadlock or other bad side effects. I changed this code so
      these arrays are modified only by calling procedure.
      I do not know why it was written in such way but I guess it
      was workaround for xHarbour bugs. In xHarbour is race condition
      inside some functions like ThreadJoin() (RTE if thread finished
      just before ThreadJoin(<pThID>)). Harbour does not have such
      problems so I simply cleaned this code making it much simpler.

I have to revert partially this code and corrected it, because with your changes s_aRunningThreads and s_aServiceThreads will never reduced in case of single thread end and leaving finished threads up and running.

    * reactivated hb_gcAll( .T. ) in the main loop for tests.
      I made some tests with linux and current uhttpd works perfectly
      without any problems with and without hb_gcAll( .t. ).
      I haven't noticed any problems. I used this scripts to make
      tests:
         #!/bin/sh
         function GT_UHTTPD()
         {
            while curl http://127.0.0.1:8082/ > /dev/null
            do
               if ! curl http://127.0.0.1:8082/serverstatus > /dev/null
               then
                  exit
               fi
               # disable it if you want to increase traffic
               if ! curl http://127.0.0.1:8082/info > /dev/null
               then
                  exit
               fi
               if [ -f stop ]
               then
                  exit
               fi
            done
         }
         for i in `seq 10`
         do
            GT_UHTTPD &>/dev/null &
         done
         wait

      on three CPU machine. Please make some test with other systems.


I'm testing your sample, but (not still tested) is this serialized or connections are submitted concurrently ? I'm creating a multithread test that sends concurrent requests to pages with a sleep inside to simulate long time reply and increase number of threads needed to reply. In any cases uhttpd has to add threads (up to max number defined, after it will reply with a busy error) in case of no available threads, but it has to release them when no more necessary (to minimum number defined).

Best regards
Francesco

_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to