Changeset 28

Show
Ignore:
Timestamp:
02/19/2005 09:38:12 PM (4 years ago)
Author:
jan
Message:

get spawing with commandline options really working
added a test-case to verify it and fixed bug #16 right away

Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • src/mod_fastcgi.c

    r9 r28  
    639639        socklen_t servlen; 
    640640         
    641         const char *appPath; 
    642         const char *hostname; 
    643         unsigned short port; 
    644          
    645         appPath    = host->bin_path->ptr; 
    646          
    647         hostname   = host->host->ptr; 
    648         port       = proc->port; 
    649  
    650641#ifndef HAVE_FORK 
    651642        return -1; 
     
    654645        if (p->conf.debug) { 
    655646                log_error_write(srv, __FILE__, __LINE__, "sdb", 
    656                                 "new proc, socket:", port, proc->socket); 
     647                                "new proc, socket:", proc->port, proc->socket); 
    657648        } 
    658649                 
     
    689680                         
    690681                         
    691                         if (NULL == (he = gethostbyname(hostname))) { 
     682                        if (NULL == (he = gethostbyname(host->host->ptr))) { 
    692683                                log_error_write(srv, __FILE__, __LINE__,  
    693                                                 "sss", "gethostbyname failed: ",  
    694                                                 hstrerror(h_errno), hostname); 
     684                                                "ssb", "gethostbyname failed: ",  
     685                                                hstrerror(h_errno), host->host); 
    695686                                return -1; 
    696687                        } 
     
    709700                         
    710701                } 
    711                 fcgi_addr_in.sin_port = htons(port); 
     702                fcgi_addr_in.sin_port = htons(proc->port); 
    712703                servlen = sizeof(fcgi_addr_in); 
    713704                 
     
    726717                pid_t child; 
    727718                int val; 
    728                 struct stat st; 
    729719                 
    730720                if (!buffer_is_empty(proc->socket)) { 
     
    733723                 
    734724                close(fcgi_fd); 
    735                  
    736                 /* can execv() work at all ? */ 
    737                 if (-1 == stat(appPath, &st)) { 
    738                         log_error_write(srv, __FILE__, __LINE__, "sss",  
    739                                 "stat failed for:", appPath, strerror(errno)); 
    740                         return -1; 
    741                 } 
    742                  
    743                  
    744725                 
    745726                /* reopen socket */ 
     
    777758                        char_array env; 
    778759                         
    779                         b = buffer_init(); 
    780760                         
    781761                        /* create environment */ 
     
    834814                        env.ptr[env.used] = NULL; 
    835815                         
     816                        b = buffer_init(); 
     817                        buffer_copy_string(b, "exec "); 
     818                        buffer_append_string_buffer(b, host->bin_path); 
     819                         
    836820                        /* exec the cgi */ 
    837                         execle("/bin/sh", "sh", "-c", appPath, NULL, env.ptr); 
    838                          
    839                         log_error_write(srv, __FILE__, __LINE__, "sss",  
    840                                         "execl failed for:", appPath, strerror(errno)); 
     821                        execle("/bin/sh", "sh", "-c", b->ptr, NULL, env.ptr); 
     822                         
     823                        log_error_write(srv, __FILE__, __LINE__, "sbs",  
     824                                        "execl failed for:", host->bin_path, strerror(errno)); 
    841825                         
    842826                        exit(errno); 
     
    22622246                        switch (fcgi_establish_connection(srv, hctx)) { 
    22632247                        case 1: 
    2264                                 /* comeback here */ 
    22652248                                fcgi_set_state(srv, hctx, FCGI_STATE_CONNECT); 
    22662249                                 
    22672250                                joblist_append(srv, con); 
     2251                                 
     2252                                /* connection is in progress, wait for an event and call getsockopt() below */ 
    22682253                                 
    22692254                                return HANDLER_WAIT_FOR_EVENT; 
  • tests/Makefile.am

    r25 r28  
    6767fastcgi-11.sh \ 
    6868fastcgi-12.sh \ 
     69fastcgi-13.sh \ 
    6970auth-01.sh \ 
    7071auth-02.sh \ 
     
    106107      fastcgi-11.conf \ 
    107108      fastcgi-12.conf \ 
     109      fastcgi-13.conf \ 
    108110      bug-06.conf \ 
    109111      bug-12.conf