Changeset 87:e78ef65c833e
- Timestamp:
- 11/11/09 08:21:04 (4 months ago)
- Author:
- roberto@…
- Branch:
- default
- Message:
-
better virtualenv support and a bit of protocol timeout fixes
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r86
|
r87
|
|
| 101 | 101 | #endif |
| 102 | 102 | |
| | 103 | char *pyhome; |
| 103 | 104 | |
| 104 | 105 | char *nl = "\r\n"; |
| … |
… |
|
| 566 | 567 | #ifndef UNBIT |
| 567 | 568 | #ifndef ROCK_SOLID |
| 568 | | while ((i = getopt (argc, argv, "s:p:t:x:d:l:O:v:b:mcaCTPiMhrR:z:w:j:")) != -1) { |
| | 569 | while ((i = getopt (argc, argv, "s:p:t:x:d:l:O:v:b:mcaCTPiMhrR:z:w:j:H:")) != -1) { |
| 569 | 570 | #else |
| 570 | | while ((i = getopt (argc, argv, "s:p:t:d:l:v:b:aCMhrR:z:j:")) != -1) { |
| | 571 | while ((i = getopt (argc, argv, "s:p:t:d:l:v:b:aCMhrR:z:j:H:")) != -1) { |
| 571 | 572 | #endif |
| 572 | 573 | #else |
| 573 | | while ((i = getopt (argc, argv, "p:t:mTPiv:b:rMR:Sz:w:C:j:")) != -1) { |
| | 574 | while ((i = getopt (argc, argv, "p:t:mTPiv:b:rMR:Sz:w:C:j:H:")) != -1) { |
| 574 | 575 | #endif |
| 575 | 576 | switch(i) { |
| 576 | 577 | case 'j': |
| 577 | 578 | test_module = optarg; |
| | 579 | break; |
| | 580 | case 'H': |
| | 581 | pyhome = optarg; |
| 578 | 582 | break; |
| 579 | 583 | #ifdef UNBIT |
| … |
… |
|
| 697 | 701 | \t-T\t\tenable threads support (no ROCK_SOLID)\n\ |
| 698 | 702 | \t-M\t\tenable master process manager\n\ |
| | 703 | \t-H <path>\tset python home/virtualenv\n\ |
| 699 | 704 | \t-h\t\tthis help\n\ |
| 700 | 705 | \t-d <logfile> daemonize and log into <logfile>\n", argv[0]); |
| … |
… |
|
| 722 | 727 | #endif |
| 723 | 728 | #endif |
| 724 | | |
| 725 | | #ifndef UNBIT |
| 726 | | #ifndef ROCK_SOLID |
| 727 | | for (i = optind; i < argc; i++) { |
| 728 | | fprintf(stderr,"Setting PythonHome to %s...\n", argv[i]); |
| 729 | | Py_SetPythonHome(argv[i]); |
| 730 | | } |
| 731 | | #endif |
| 732 | | #endif |
| | 729 | |
| | 730 | |
| | 731 | if (pyhome != NULL) { |
| | 732 | fprintf(stderr,"Setting PythonHome to %s...\n", pyhome); |
| | 733 | Py_SetPythonHome(pyhome); |
| | 734 | } |
| 733 | 735 | |
| 734 | 736 | #ifdef PYTHREE |
| … |
… |
|
| 1043 | 1045 | } |
| 1044 | 1046 | rlen = read(wsgi_poll.fd, &wsgi_req, 4) ; |
| 1045 | | if (rlen != 4){ |
| | 1047 | if (rlen > 0 && rlen < 4) { |
| | 1048 | i = rlen ; |
| | 1049 | while(i < 4) { |
| | 1050 | rlen = poll(&wsgi_poll, 1, socket_timeout*1000) ; |
| | 1051 | if (rlen < 0) { |
| | 1052 | perror("poll()"); |
| | 1053 | exit(1); |
| | 1054 | } |
| | 1055 | else if (rlen == 0) { |
| | 1056 | fprintf(stderr, "timeout waiting for header. skip request.\n"); |
| | 1057 | close(wsgi_poll.fd); |
| | 1058 | break ; |
| | 1059 | } |
| | 1060 | rlen = read(wsgi_poll.fd, (char *)(&wsgi_req)+i, 4-i); |
| | 1061 | if (rlen <= 0) { |
| | 1062 | fprintf(stderr, "broken header. skip request.\n"); |
| | 1063 | close(wsgi_poll.fd); |
| | 1064 | break ; |
| | 1065 | } |
| | 1066 | i += rlen; |
| | 1067 | } |
| | 1068 | if (i < 4) { |
| | 1069 | continue; |
| | 1070 | } |
| | 1071 | } |
| | 1072 | else if (rlen <= 0){ |
| 1046 | 1073 | fprintf(stderr,"invalid request header size: %d...skip\n", rlen); |
| 1047 | 1074 | close(wsgi_poll.fd); |
| … |
… |
|
| 1068 | 1095 | break ; |
| 1069 | 1096 | } |
| 1070 | | i += read(wsgi_poll.fd, buffer, wsgi_req.size-i); |
| | 1097 | rlen = read(wsgi_poll.fd, buffer, wsgi_req.size-i); |
| | 1098 | if (rlen <= 0) { |
| | 1099 | fprintf(stderr, "broken vars. skip request.\n"); |
| | 1100 | close(wsgi_poll.fd); |
| | 1101 | break ; |
| | 1102 | } |
| | 1103 | i += rlen ; |
| 1071 | 1104 | } |
| 1072 | 1105 | |