Changeset 883
- Timestamp:
- 08/07/07 23:07:54 (1 year ago)
- Files:
-
- cherokee/trunk/ChangeLog (modified) (1 diff)
- cherokee/trunk/cherokee/buffer.c (modified) (1 diff)
- cherokee/trunk/cherokee/cherokee_logrotate.c (modified) (1 diff)
- cherokee/trunk/cherokee/fdpoll-epoll.c (modified) (5 diffs)
- cherokee/trunk/cherokee/fdpoll-kqueue.c (modified) (1 diff)
- cherokee/trunk/cherokee/fdpoll-port.c (modified) (7 diffs)
- cherokee/trunk/cherokee/handler_cgi.c (modified) (3 diffs)
- cherokee/trunk/cherokee/logger_writer.c (modified) (2 diffs)
- cherokee/trunk/cherokee/macros.h (modified) (1 diff)
- cherokee/trunk/cherokee/ncpus.c (modified) (3 diffs)
- cherokee/trunk/cherokee/server.c (modified) (3 diffs)
- cherokee/trunk/cherokee/socket.c (modified) (5 diffs)
- cherokee/trunk/cherokee/util.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator_ldap.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/ChangeLog
r881 r883 1 1 2007-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. 2 12 3 13 * cherokee/virtual_server.h, cherokee/virtual_server.c, cherokee/trunk/cherokee/buffer.c
r857 r883 908 908 case EIO: return ret_error; 909 909 } 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); 914 912 return ret_error; 915 913 } cherokee/trunk/cherokee/cherokee_logrotate.c
r784 r883 177 177 re = rename (argv[2], logname.buf); 178 178 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); 181 180 } 182 181 printf ("Log file '%s' moved to '%s' successfully\n", argv[2], logname.buf); cherokee/trunk/cherokee/fdpoll-epoll.c
r811 r883 110 110 111 111 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); 115 113 return ret_error; 116 114 } … … 138 136 139 137 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); 143 139 return ret_error; 144 140 } … … 230 226 231 227 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); 235 229 return ret_error; 236 230 } … … 316 310 */ 317 311 #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); 321 313 #endif 322 314 _free (n); … … 326 318 re = fcntl (n->ep_fd, F_SETFD, FD_CLOEXEC); 327 319 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}'"); 331 321 _free (n); 332 322 return ret_error; cherokee/trunk/cherokee/fdpoll-kqueue.c
r811 r883 175 175 fdp->nchanges=0; 176 176 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}'"); 179 178 return 0; 180 179 } else if ( n_events > 0 ) { cherokee/trunk/cherokee/fdpoll-port.c
r811 r883 82 82 83 83 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); 86 85 return ret_error; 87 86 } … … 121 120 rc = fd_associate(fdp, fd, (rw == FDPOLL_MODE_WRITE ? WRITE : READ)); 122 121 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); 125 123 return ret_error; 126 124 } … … 140 138 fd); /* object */ 141 139 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); 144 141 return ret_error; 145 142 } … … 173 170 &timeout); 174 171 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}'"); 177 173 return 0; 178 174 } … … 190 186 &fdp->port_readyfds, &timeout); 191 187 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}'"); 194 189 return 0; 195 190 } … … 204 199 fdp->port_events[i].portev_user); 205 200 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}'"); 208 202 } 209 203 } … … 256 250 (rw == FDPOLL_MODE_WRITE ? WRITE : READ)); 257 251 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); 260 253 return ret_error; 261 254 } cherokee/trunk/cherokee/handler_cgi.c
r869 r883 459 459 460 460 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); 463 462 return ret_error; 464 463 } … … 564 563 if (re < 0) { 565 564 int err = errno; 565 char buferr[ERROR_MAX_BUFSIZE]; 566 566 567 567 switch (err) { … … 573 573 } 574 574 575 {576 char buferr[ERROR_MAX_BUFSIZE];577 575 cherokee_logger_write_string (CONN_VSRV(conn)->logger, 578 576 "couldn't execute '%s': %s", 579 577 absolute_path, 580 578 cherokee_strerror_r(err, buferr, sizeof(buferr))); 581 }582 579 exit(1); 583 580 } cherokee/trunk/cherokee/logger_writer.c
r784 r883 201 201 202 202 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}'"); 205 204 return ret_error; 206 205 } … … 223 222 224 223 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}'"); 229 225 break; 230 226 cherokee/trunk/cherokee/macros.h
r812 r883 281 281 */ 282 282 #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__) 288 290 #endif 289 291 cherokee/trunk/cherokee/ncpus.c
r863 r883 58 58 return 0; 59 59 } else { 60 char buferr[ERROR_MAX_BUFSIZE];61 fprintf (stderr, "pstat_getdynamic failed: %s",62 cherokee_strerror_r(errno, buferr, sizeof(buferr)));63 60 *ncpus = -1; 61 PRINT_ERRNO (errno, "pstat_getdynamic failed: '${errno}'"); 64 62 return EXIT_DISTCC_FAILED; 65 63 } … … 113 111 return 0; 114 112 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}'"); 118 114 return EXIT_DISTCC_FAILED; 119 115 } … … 143 139 144 140 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}'"); 148 142 return EXIT_DISTCC_FAILED; 149 143 } else if (*ncpus == 0) { cherokee/trunk/cherokee/server.c
r857 r883 1128 1128 srv->chrooted = (re == 0); 1129 1129 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); 1132 1131 return ret_error; 1133 1132 } … … 1145 1144 re = chdir ("/"); 1146 1145 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}'"); 1149 1147 return ret_error; 1150 1148 } … … 2003 2001 file = fopen (srv->pidfile.buf, "w"); 2004 2002 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); 2007 2004 return ret_error; 2008 2005 } cherokee/trunk/cherokee/socket.c
r881 r883 954 954 return ret_error; 955 955 } 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)); 961 958 return ret_error; 962 959 } … … 1100 1097 return ret_error; 1101 1098 } 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)); 1107 1101 return ret_error; 1108 1102 } … … 1285 1279 return ret_error; 1286 1280 } 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)); 1292 1283 return ret_error; 1293 1284 } … … 1631 1622 return ret_eagain; 1632 1623 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}'"); 1639 1625 return ret_error; 1640 1626 } … … 1802 1788 if (re < 0) { 1803 1789 int err = errno; 1804 char buferr[ERROR_MAX_BUFSIZE]; 1805 PRINT_ERR OR ("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); 1807 1793 return ret_error; 1808 1794 } cherokee/trunk/cherokee/util.c
r865 r883 1349 1349 cherokee_buffer_t buffer = CHEROKEE_BUF_INIT; 1350 1350 1351 cherokee_buffer_add_str (&buffer, "ERROR: ");1352 1351 errstr = cherokee_strerror_r (error, err_tmp, sizeof(err_tmp)); 1353 1352 1353 cherokee_buffer_ensure_size (&buffer, 128); 1354 1354 va_start (ap, format); 1355 1355 cherokee_buffer_add_va_list (&buffer, format, ap); 1356 1356 va_end (ap); 1357 1357 1358 cherokee_buffer_add_str (&buffer, "\n");1359 1360 1358 cherokee_buffer_replace_string (&buffer, "${errno}", 8, errstr, strlen(errstr)); 1361 PRINT_ MSG_S (buffer.buf);1359 PRINT_ERROR_S (buffer.buf); 1362 1360 1363 1361 cherokee_buffer_mrproper (&buffer); 1364 1362 } 1363 1365 1364 1366 1365 ret_t cherokee/trunk/cherokee/validator_ldap.c
r784 r883 159 159 ldap->conn = ldap_init (props->server.buf, props->port); 160 160 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); 164 163 return ret_error; 165 164 }