Changeset 5169
- Timestamp:
- 05/04/11 19:42:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-http.c
r5166 r5169 18 18 extern void restart_cardreader(struct s_reader *rdr, int32_t restart); 19 19 20 static int 32_t running = 1, fdopened = 0;20 static int8_t running = 1; 21 21 pthread_mutex_t http_lock; 22 22 … … 2663 2663 if(!apicall){ 2664 2664 tpl_addVar(vars, TPLADD, "STYLESHEET", CSS); 2665 tpl_ printf(vars, TPLADD, "REFRESHTIME", "2");2665 tpl_addVar(vars, TPLADD, "REFRESHTIME", "5"); 2666 2666 tpl_addVar(vars, TPLADD, "REFRESHURL", "status.html"); 2667 2667 tpl_addVar(vars, TPLADD, "REFRESH", tpl_getTpl(vars, "REFRESH")); … … 3463 3463 } 3464 3464 if (ok){ 3465 fdopened = 1;3466 3465 process_request((FILE *)ssl, in); 3467 3466 } else { 3468 3467 FILE *f; 3469 3468 f = fdopen(s, "r+"); 3470 fdopened = 1;3471 3469 if(f != NULL) { 3472 3470 char *ptr, *filebuf = NULL, *host = NULL; … … 3501 3499 FILE *f; 3502 3500 f = fdopen(s, "r+"); 3503 fdopened = 1;3504 3501 if(f != NULL) { 3505 3502 process_request(f, in); … … 3530 3527 struct sockaddr_in remote; 3531 3528 struct timeval stimeout; 3532 pthread_mutex_init(&http_lock, NULL);3529 struct s_connection *conn; 3533 3530 3534 3531 socklen_t len = sizeof(remote); 3535 3532 /* Create random string for nonce value generation */ 3536 3533 create_rand_str(noncekey,32); 3534 3535 if(pthread_mutex_init(&http_lock, NULL)){ 3536 cs_log("HTTP Server: Error creating mutex! (errno=%d %s)", errno, strerror(errno)); 3537 return; 3538 }; 3537 3539 3538 3540 /* Startup server */ … … 3571 3573 } 3572 3574 cs_log("HTTP Server listening on port %d%s", cfg.http_port, cfg.http_use_ssl ? " (SSL)" : ""); 3573 struct pollfd pfd2[1];3574 int32_t rc;3575 pfd2[0].fd = sock;3576 pfd2[0].events = (POLLIN | POLLPRI);3577 3575 3578 3576 #ifdef WITH_SSL … … 3587 3585 3588 3586 while (running) { 3589 struct s_connection *conn; 3590 rc = poll(pfd2, 1, 1000); 3591 3592 if (rc > 0) { 3593 if((s = accept(sock, (struct sockaddr *) &remote, &len)) < 0) { 3587 if((s = accept(sock, (struct sockaddr *) &remote, &len)) < 0) { 3588 if(errno != EAGAIN){ 3594 3589 cs_log("HTTP Server: Error calling accept() (errno=%d %s)", errno, strerror(errno)); 3595 break; 3596 } 3590 cs_sleepms(100); 3591 } else cs_sleepms(5); 3592 continue; 3593 } else { 3597 3594 if(!cs_malloc(&conn, sizeof(struct s_connection), -1)){ 3598 3595 close(s); … … 3627 3624 pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE); 3628 3625 #endif 3629 fdopened = 0;3630 3626 if (pthread_create(&workthread, &attr, serve_process, (void *)conn)) { 3631 3627 cs_log("ERROR: can't create thread for webif"); … … 3633 3629 free(conn); 3634 3630 } 3635 else { 3636 pthread_detach(workthread); 3637 int8_t i = 0; 3638 // Wait until the thread has finished opening the file descriptor 3639 while(!fdopened && i < 50){ 3640 ++i; 3641 cs_sleepms(2); 3642 } 3643 } 3631 else 3632 pthread_detach(workthread); 3644 3633 pthread_attr_destroy(&attr); 3645 3634 } 3646 3635 } 3636 3647 3637 #ifdef WITH_SSL 3648 3638 if (ssl_active){
Note:
See TracChangeset
for help on using the changeset viewer.