Browse code

webkernel: fix definition of (clientblock).acquired, fix freeing of clients' fd.

Dario Rodriguez authored on 30/06/2014 21:02:36
Showing 1 changed files
... ...
@@ -67,7 +67,7 @@ typedef struct wk_client {
67 67
 typedef struct wk_clientblock {
68 68
         int sizeclients;
69 69
         int usedclients;
70
-        unsigned char acquired[CLIENTBLOCKBLOCK/8];
70
+        unsigned char acquired[CLIENTBLOCK/8];
71 71
         wk_client *clients;
72 72
 } wk_clientblock;
73 73
 
... ...
@@ -169,7 +169,7 @@ wk_free(wk *paramweb)
169 169
                         for(k=0x1,n=0;n<8;n++,k<<=1) {
170 170
                                 if(!(cb->acquired[j>>3]&k))
171 171
                                         continue;
172
-                                client=cb->clients+j+k;
172
+                                client=cb->clients+j+n;
173 173
                                 if(client->fd!=-1) {
174 174
                                         sselect_delread(web->ssel,client->fd);
175 175
                                         sselect_delwrite(web->ssel,client->fd);
... ...
@@ -821,6 +821,7 @@ wk_clientacquire(_wk *web)
821 821
                 if((cb->clients=malloc(sizeof(wk_client)*CLIENTBLOCK))==NULL)
822 822
                         return(NULL); /* insufficient memory */
823 823
                 memset(cb->clients,0,sizeof(wk_client)*CLIENTBLOCK);
824
+                memset(cb->acquired,0,sizeof(cb->acquired));
824 825
                 cb->sizeclients=CLIENTBLOCK;
825 826
                 cb->usedclients=0;
826 827
                 web->usedclientblocks++;