comparison src/c/urweb.c @ 864:6304f5e8fbb4

FastCGI working with lighttpd
author Adam Chlipala <adamc@hcoop.net>
date Sat, 27 Jun 2009 19:07:28 -0400
parents 305bc0a431de
children 03e7f111fe99
comparison
equal deleted inserted replaced
863:305bc0a431de 864:6304f5e8fbb4
204 on_success = s; 204 on_success = s;
205 } 205 }
206 206
207 void uw_client_connect(unsigned id, int pass, int sock, 207 void uw_client_connect(unsigned id, int pass, int sock,
208 int (*send)(int sockfd, const void *buf, ssize_t len), 208 int (*send)(int sockfd, const void *buf, ssize_t len),
209 int (*close)(int fd)) { 209 int (*close)(int fd),
210 void *logger_data, uw_logger log_error) {
210 client *c = find_client(id); 211 client *c = find_client(id);
211 212
212 if (c == NULL) { 213 if (c == NULL) {
213 close(sock); 214 close(sock);
214 fprintf(stderr, "Out-of-bounds client request (%u)\n", id); 215 log_error(logger_data, "Out-of-bounds client request (%u)\n", id);
215 return; 216 return;
216 } 217 }
217 218
218 pthread_mutex_lock(&c->lock); 219 pthread_mutex_lock(&c->lock);
219 220
220 if (c->mode != USED) { 221 if (c->mode != USED) {
221 pthread_mutex_unlock(&c->lock); 222 pthread_mutex_unlock(&c->lock);
222 close(sock); 223 close(sock);
223 fprintf(stderr, "Client request for unused slot (%u)\n", id); 224 log_error(logger_data, "Client request for unused slot (%u)\n", id);
224 return; 225 return;
225 } 226 }
226 227
227 if (pass != c->pass) { 228 if (pass != c->pass) {
228 pthread_mutex_unlock(&c->lock); 229 pthread_mutex_unlock(&c->lock);
229 close(sock); 230 close(sock);
230 fprintf(stderr, "Wrong client password (%u, %d)\n", id, pass); 231 log_error(logger_data, "Wrong client password (%u, %d)\n", id, pass);
231 return; 232 return;
232 } 233 }
233 234
234 if (c->sock != -1) { 235 if (c->sock != -1) {
235 c->close(c->sock); 236 c->close(c->sock);
561 } 562 }
562 } else { 563 } else {
563 client *c = new_client(); 564 client *c = new_client();
564 use_client(c); 565 use_client(c);
565 ctx->client = c; 566 ctx->client = c;
566 } 567 }
567 } 568 }
568 } 569 }
569 570
570 failure_kind uw_begin(uw_context ctx, char *path) { 571 failure_kind uw_begin(uw_context ctx, char *path) {
571 int r = setjmp(ctx->jmp_buf); 572 int r = setjmp(ctx->jmp_buf);