Changeset 883

Show
Ignore:
Timestamp:
08/07/07 23:07:54 (1 year ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r881 r883  
    112007-08-07  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/cherokee/validator_ldap.c, cherokee/fdpoll-epoll.c, 
     4        cherokee/macros.h, cherokee/buffer.c, cherokee/logger_writer.c, 
     5        cherokee/ncpus.c, cherokee/util.c, cherokee/fdpoll-port.c, 
     6        cherokee/handler_cgi.c, cherokee/cherokee_logrotate.c, 
     7        cherokee/fdpoll-kqueue.c, cherokee/server.c, cherokee/socket.c: 
     8        errno related error reports cleaned up. They now use 
     9        PRINT_ERRNO and cherokee_print_errno() underneath. 
     10         
     11        * cherokee/macros.h (PRINT_ERRNO): Added new macro. 
    212 
    313        * cherokee/virtual_server.h, cherokee/virtual_server.c, 
  • cherokee/trunk/cherokee/buffer.c

    r857 r883  
    908908                case EIO:        return ret_error; 
    909909                } 
    910                 { 
    911                 char buferr[ERROR_MAX_BUFSIZE]; 
    912                 PRINT_ERROR ("ERROR: read(%d, %u,..) -> errno=%d '%s'\n", fd, size, errno, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
    913                 } 
     910 
     911                PRINT_ERRNO (errno, "read(%d, %u,..): '${errno}'", fd, size); 
    914912                return ret_error; 
    915913        } 
  • cherokee/trunk/cherokee/cherokee_logrotate.c

    r784 r883  
    177177        re = rename (argv[2], logname.buf); 
    178178        if (re != 0) { 
    179                 char buferr[ERROR_MAX_BUFSIZE]; 
    180                 PRINT_ERROR("Could not move '%s' to '%s': %s\n", argv[2], logname.buf, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     179                PRINT_ERRNO (errno, "Could not move '%s' to '%s': '${errno}'", argv[2], logname.buf); 
    181180        } 
    182181        printf ("Log file '%s' moved to '%s' successfully\n", argv[2], logname.buf); 
  • cherokee/trunk/cherokee/fdpoll-epoll.c

    r811 r883  
    110110 
    111111        if (epoll_ctl (fdp->ep_fd, EPOLL_CTL_ADD, fd, &ev) < 0) { 
    112                 char buferr[ERROR_MAX_BUFSIZE]; 
    113                 PRINT_ERROR ("ERROR: epoll_ctl(%d, EPOLL_CTL_ADD, %d): %s\n",  
    114                                 fdp->ep_fd, fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     112                PRINT_ERRNO (errno, "epoll_ctl(%d, EPOLL_CTL_ADD, %d): '${errno}'", fdp->ep_fd, fd); 
    115113                return ret_error; 
    116114        } 
     
    138136 
    139137        if (epoll_ctl(fdp->ep_fd, EPOLL_CTL_DEL, fd, &ev) < 0) { 
    140                 char buferr[ERROR_MAX_BUFSIZE]; 
    141                 PRINT_ERROR ("ERROR: epoll_ctl(%d, EPOLL_CTL_DEL, %d): %s\n",  
    142                                 fdp->ep_fd, fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     138                PRINT_ERRNO (errno, "epoll_ctl(%d, EPOLL_CTL_DEL, %d): '${errno}'", fdp->ep_fd, fd); 
    143139                return ret_error; 
    144140        } 
     
    230226 
    231227        if (epoll_ctl(fdp->ep_fd, EPOLL_CTL_MOD, fd, &ev) < 0) { 
    232                 char buferr[ERROR_MAX_BUFSIZE]; 
    233                 PRINT_ERROR ("ERROR: epoll_ctl (%d, EPOLL_CTL_MOD, %d): %s\n", 
    234                              fdp->ep_fd, fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     228                PRINT_ERRNO (errno, "epoll_ctl(%d, EPOLL_CTL_MOD, %d): '${errno}'", fdp->ep_fd, fd); 
    235229                return ret_error; 
    236230        } 
     
    316310                 */ 
    317311#if 0 
    318                 char buferr[ERROR_MAX_BUFSIZE]; 
    319                 PRINT_ERROR ("ERROR: epoll_create(%d): %s\n",  
    320                              nfd->nfiles+1, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     312                PRINT_ERRNO (errno, "epoll_create(%d): '${errno}'", nfd->nfiles+1); 
    321313#endif 
    322314                _free (n); 
     
    326318        re = fcntl (n->ep_fd, F_SETFD, FD_CLOEXEC); 
    327319        if (re < 0) { 
    328                 char buferr[ERROR_MAX_BUFSIZE]; 
    329                 PRINT_ERROR ("ERROR: could not set CloseExec to the epoll descriptor: fcntl: %s\n",  
    330                              cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     320                PRINT_ERRNO (errno, "Could not set CloseExec to the epoll descriptor: fcntl: '${errno}'"); 
    331321                _free (n); 
    332322                return ret_error;                
  • cherokee/trunk/cherokee/fdpoll-kqueue.c

    r811 r883  
    175175        fdp->nchanges=0; 
    176176        if ( n_events < 0 ) { 
    177                 char buferr[ERROR_MAX_BUFSIZE]; 
    178                 PRINT_ERROR ("ERROR: kevent: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     177                PRINT_ERRNO (errno, "kevent: '${errno}'"); 
    179178                return 0; 
    180179        } else if ( n_events > 0 ) { 
  • cherokee/trunk/cherokee/fdpoll-port.c

    r811 r883  
    8282 
    8383        if ( rc == -1 ) { 
    84                 char buferr[ERROR_MAX_BUFSIZE]; 
    85                 PRINT_ERROR ("ERROR: port_associate: fd %d: %s\n", fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     84                PRINT_ERRNO (errno, "port_associate: fd %d: '${errno}'", fd); 
    8685                return ret_error; 
    8786        } 
     
    121120        rc = fd_associate(fdp, fd, (rw == FDPOLL_MODE_WRITE ? WRITE : READ)); 
    122121        if ( rc == -1 ) { 
    123                 char buferr[ERROR_MAX_BUFSIZE]; 
    124                 PRINT_ERROR ("ERROR: port_associate: fd %d: %s\n", fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     122                PRINT_ERRNO (errno, "port_associate: fd %d: '${errno}'", fd); 
    125123                return ret_error; 
    126124        } 
     
    140138                              fd);            /* object */ 
    141139        if ( rc == -1 ) { 
    142                 char buferr[ERROR_MAX_BUFSIZE]; 
    143                 PRINT_ERROR ("ERROR: port_dissociate: %d,%s\n", fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     140                PRINT_ERRNO (errno, "port_dissociate: fd %d: '${errno}'", fd); 
    144141                return ret_error; 
    145142        } 
     
    173170                        &timeout); 
    174171        if ( rc < 0 ) { 
    175                 char buferr[ERROR_MAX_BUFSIZE]; 
    176                 PRINT_ERROR ("ERROR: port_getn: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     172                PRINT_ERRNO (errno, "port_getn: '${errno}'"); 
    177173                return 0; 
    178174        } 
     
    190186                        &fdp->port_readyfds, &timeout); 
    191187        if ( ( (rc < 0) && (errno != ETIME) ) || (fdp->port_readyfds == -1)) { 
    192                 char buferr[ERROR_MAX_BUFSIZE]; 
    193                 PRINT_ERROR ("ERROR: port_getn: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     188                PRINT_ERRNO (errno, "port_getn: '${errno}'"); 
    194189                return 0; 
    195190        } 
     
    204199                                   fdp->port_events[i].portev_user); 
    205200                if ( rc < 0 ) { 
    206                         char buferr[ERROR_MAX_BUFSIZE]; 
    207                         PRINT_ERROR ("ERROR: port_associate: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     201                        PRINT_ERRNO (errno, "port_associate: '${errno}'"); 
    208202                } 
    209203        } 
     
    256250                            (rw == FDPOLL_MODE_WRITE ? WRITE   : READ)); 
    257251        if ( rc == -1 ) { 
    258                 char buferr[ERROR_MAX_BUFSIZE]; 
    259                 PRINT_ERROR ("ERROR: port_associate: fd %d: %s\n", fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     252                PRINT_ERRNO (errno, "port_associate: fd %d: '${errno}'", fd); 
    260253                return ret_error; 
    261254        } 
  • cherokee/trunk/cherokee/handler_cgi.c

    r869 r883  
    459459 
    460460        if (fcntl (fd, F_SETFL, flags) == -1) { 
    461                 char buferr[ERROR_MAX_BUFSIZE]; 
    462                 PRINT_ERROR ("ERROR: Setting pipe properties fd=%d: %s\n", fd, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     461                PRINT_ERRNO (errno, "Setting pipe properties fd=%d: '${errno}'", fd); 
    463462                return ret_error; 
    464463        }        
     
    564563        if (re < 0) { 
    565564                int err = errno; 
     565                char buferr[ERROR_MAX_BUFSIZE]; 
    566566 
    567567                switch (err) { 
     
    573573                } 
    574574 
    575                 { 
    576                 char buferr[ERROR_MAX_BUFSIZE]; 
    577575                cherokee_logger_write_string (CONN_VSRV(conn)->logger,  
    578576                        "couldn't execute '%s': %s", 
    579577                        absolute_path, 
    580578                        cherokee_strerror_r(err, buferr, sizeof(buferr))); 
    581                 } 
    582579                exit(1); 
    583580        } 
  • cherokee/trunk/cherokee/logger_writer.c

    r784 r883  
    201201 
    202202        if (pipe (to_log_fds)) {  
    203                 char buferr[ERROR_MAX_BUFSIZE]; 
    204                 PRINT_MSG ("Pipe error: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     203                PRINT_ERRNO (errno, "Pipe error: '${errno}'"); 
    205204                return ret_error; 
    206205        } 
     
    223222 
    224223        case -1: 
    225                 { 
    226                 char buferr[ERROR_MAX_BUFSIZE]; 
    227                 PRINT_MSG ("Fork failed: %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
    228                 } 
     224                PRINT_ERRNO (errno, "Fork failed: '${errno}'"); 
    229225                break; 
    230226 
  • cherokee/trunk/cherokee/macros.h

    r812 r883  
    281281 */ 
    282282#ifdef __GNUC__ 
    283 # define PRINT_ERROR(fmt,arg...) fprintf(stderr, "%s:%d: "fmt, __FILE__, __LINE__, ##arg) 
    284 # define PRINT_MSG(fmt,arg...)   fprintf(stderr, fmt, ##arg) 
    285 #else 
    286 # define PRINT_ERROR(fmt,...)    fprintf(stderr, "%s:%d: "fmt, __FILE__, __LINE__, __VA_ARGS__) 
    287 # define PRINT_MSG(fmt,...)      fprintf(stderr, fmt, __VA_ARGS__) 
     283# define PRINT_MSG(fmt,arg...)       fprintf(stderr, fmt, ##arg) 
     284# define PRINT_ERROR(fmt,arg...)     fprintf(stderr, "%s:%d: "fmt, __FILE__, __LINE__, ##arg) 
     285# define PRINT_ERRNO(err,fmt,arg...) cherokee_print_errno(err, fmt"\n", ##arg) 
     286#else 
     287# define PRINT_MSG(fmt,...)          fprintf(stderr, fmt, __VA_ARGS__) 
     288# define PRINT_ERROR(fmt,...)        fprintf(stderr, "%s:%d: "fmt, __FILE__, __LINE__, __VA_ARGS__) 
     289# define PRINT_ERRNO(err,fmt,...)    cherokee_print_errno(err, fmt"\n", __VA_ARGS__) 
    288290#endif 
    289291 
  • cherokee/trunk/cherokee/ncpus.c

    r863 r883  
    5858                return 0; 
    5959        } else { 
    60                 char buferr[ERROR_MAX_BUFSIZE]; 
    61                 fprintf (stderr, "pstat_getdynamic failed: %s", 
    62                         cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
    6360                *ncpus = -1; 
     61                PRINT_ERRNO (errno, "pstat_getdynamic failed: '${errno}'"); 
    6462                return EXIT_DISTCC_FAILED; 
    6563        } 
     
    113111                return 0; 
    114112        else { 
    115                 char buferr[ERROR_MAX_BUFSIZE]; 
    116                 fprintf(stderr,"sysctl(CTL_HW:HW_NCPU) failed: %s", 
    117                         cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     113                PRINT_ERRNO (errno, "sysctl(CTL_HW:HW_NCPU) failed: '${errno}'"); 
    118114                return EXIT_DISTCC_FAILED; 
    119115        } 
     
    143139     
    144140        if (*ncpus == -1) { 
    145                 char buferr[ERROR_MAX_BUFSIZE]; 
    146                 fprintf(stderr,"sysconf(_SC_NPROCESSORS_ONLN) failed: %s", 
    147                         cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     141                PRINT_ERRNO (errno, "sysconf(_SC_NPROCESSORS_ONLN) failed: '${errno}'"); 
    148142                return EXIT_DISTCC_FAILED; 
    149143        } else if (*ncpus == 0) { 
  • cherokee/trunk/cherokee/server.c

    r857 r883  
    11281128                srv->chrooted = (re == 0); 
    11291129                if (srv->chrooted == 0) { 
    1130                         char buferr[ERROR_MAX_BUFSIZE]; 
    1131                         PRINT_ERROR ("Cannot chroot() to '%s': %s\n", srv->chroot.buf, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     1130                        PRINT_ERRNO (errno, "Cannot chroot() to '%s': '${errno}'", srv->chroot.buf); 
    11321131                        return ret_error; 
    11331132                } 
     
    11451144        re = chdir ("/"); 
    11461145        if (re < 0) { 
    1147                 char buferr[ERROR_MAX_BUFSIZE]; 
    1148                 PRINT_ERROR ("Couldn't chdir(\"/\"): %s\n", cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     1146                PRINT_ERRNO (errno, "Couldn't chdir(\"/\"): '${errno}'"); 
    11491147                return ret_error; 
    11501148        } 
     
    20032001        file = fopen (srv->pidfile.buf, "w"); 
    20042002        if (file == NULL) { 
    2005                 char buferr[ERROR_MAX_BUFSIZE]; 
    2006                 PRINT_MSG ("ERROR: Can't write PID file '%s': %s\n", srv->pidfile.buf, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     2003                PRINT_ERRNO (errno, "Cannot write PID file '%s': '${errno}'", srv->pidfile.buf); 
    20072004                return ret_error; 
    20082005        } 
  • cherokee/trunk/cherokee/socket.c

    r881 r883  
    954954                                return ret_error; 
    955955                        } 
    956                         {        
    957                         char buferr[ERROR_MAX_BUFSIZE]; 
    958                         PRINT_ERROR ("ERROR: write(%d, ..) -> errno=%d '%s'\n",  
    959                                 SOCKET_FD(socket), err, cherokee_strerror_r(err, buferr, sizeof(buferr))); 
    960                         } 
     956 
     957                        PRINT_ERRNO (err, "write(%d, ..): '${errno}'", SOCKET_FD(socket)); 
    961958                        return ret_error; 
    962959                } 
     
    11001097                                return ret_error; 
    11011098                        } 
    1102                         { 
    1103                         char buferr[ERROR_MAX_BUFSIZE]; 
    1104                         PRINT_ERROR ("ERROR: read(%d, ..) -> errno=%d '%s'\n",  
    1105                                 SOCKET_FD(socket), err, cherokee_strerror_r(err, buferr, sizeof(buferr))); 
    1106                         } 
     1099 
     1100                        PRINT_ERRNO (err, "read(%d, ..): '${errno}'", SOCKET_FD(socket)); 
    11071101                        return ret_error; 
    11081102                } 
     
    12851279                                return ret_error; 
    12861280                        } 
    1287                         { 
    1288                         char buferr[ERROR_MAX_BUFSIZE]; 
    1289                         PRINT_ERROR ("ERROR: writev(%d, ..) -> errno=%d '%s'\n",  
    1290                              SOCKET_FD(socket), err, cherokee_strerror_r(err, buferr, sizeof(buferr))); 
    1291                         } 
     1281 
     1282                        PRINT_ERRNO (err, "writev(%d, ..): '${errno}'", SOCKET_FD(socket)); 
    12921283                        return ret_error; 
    12931284                } 
     
    16311622                        return ret_eagain; 
    16321623                default: 
    1633 #if 1 
    1634                         { 
    1635                         char buferr[ERROR_MAX_BUFSIZE]; 
    1636                         PRINT_ERROR ("ERROR: Can not connect: %s\n", cherokee_strerror_r(err, buferr, sizeof(buferr))); 
    1637                         } 
    1638 #endif 
     1624                        PRINT_ERRNO (err, "Cannot connect: '${errno}'"); 
    16391625                        return ret_error; 
    16401626                } 
     
    18021788        if (re < 0) { 
    18031789                int err = errno; 
    1804                 char buferr[ERROR_MAX_BUFSIZE]; 
    1805                 PRINT_ERROR ("Couldn't set SO_RCVTIMEO, fd=%d, timeout=%d: %s\n",  
    1806                              socket->socket, timeout, cherokee_strerror_r(err, buferr, sizeof(buferr))); 
     1790 
     1791                PRINT_ERRNO (err, "Couldn't set SO_RCVTIMEO, fd=%d, timeout=%d: '${errno}'",  
     1792                             SOCKET_FD(socket), timeout); 
    18071793                return ret_error; 
    18081794        } 
  • cherokee/trunk/cherokee/util.c

    r865 r883  
    13491349        cherokee_buffer_t buffer = CHEROKEE_BUF_INIT; 
    13501350 
    1351         cherokee_buffer_add_str (&buffer, "ERROR: "); 
    13521351        errstr = cherokee_strerror_r (error, err_tmp, sizeof(err_tmp)); 
    13531352 
     1353        cherokee_buffer_ensure_size (&buffer, 128); 
    13541354        va_start (ap, format); 
    13551355        cherokee_buffer_add_va_list (&buffer, format, ap); 
    13561356        va_end (ap); 
    13571357 
    1358         cherokee_buffer_add_str (&buffer, "\n"); 
    1359  
    13601358        cherokee_buffer_replace_string (&buffer, "${errno}", 8, errstr, strlen(errstr)); 
    1361         PRINT_MSG_S (buffer.buf); 
     1359        PRINT_ERROR_S (buffer.buf); 
    13621360 
    13631361        cherokee_buffer_mrproper (&buffer); 
    13641362} 
     1363 
    13651364 
    13661365ret_t  
  • cherokee/trunk/cherokee/validator_ldap.c

    r784 r883  
    159159        ldap->conn = ldap_init (props->server.buf, props->port); 
    160160        if (ldap->conn == NULL) { 
    161                 char buferr[ERROR_MAX_BUFSIZE]; 
    162                 PRINT_ERROR ("ERROR: LDAP validator: Couldn't connect to LDAP: %s:%d: %s\n",  
    163                              props->server.buf, props->port, cherokee_strerror_r(errno, buferr, sizeof(buferr))); 
     161                PRINT_ERRNO (errno, "Couldn't connect to LDAP: %s:%d: '${errno}'",  
     162                             props->server.buf, props->port); 
    164163                return ret_error; 
    165164        }