Skip to content

Commit

Permalink
git-svn-id: svn://cherokee-project.com/cherokee/trunk@637 5dc97367-97…
Browse files Browse the repository at this point in the history
…f1-0310-9951-d761b3857238
  • Loading branch information
alobbs committed Jan 22, 2007
1 parent 2b0a518 commit 89220c0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 22 deletions.
28 changes: 28 additions & 0 deletions ChangeLog
@@ -1,3 +1,31 @@
2007-01-22 A.D.F <adefacc@tin.it>

* cherokee/connection-protected.h:
- rename cherokee_connection_pre_lingering_close()
to cherokee_connection_shutdown_wr();

* cherokee/connection.c:
- rename cherokee_connection_pre_lingering_close()
to cherokee_connection_shutdown_wr();
- fix cherokee_connection_mrproper()
in order to always execute cleanup even if
one function fails.

* cherokee/thread.c:
- rename cherokee_connection_pre_lingering_close()
to cherokee_connection_shutdown_wr();

* cherokee/socket.c:
- added ENOTCONN to the error codes which are not logged
(because they can happen under certain conditions);
- cherokee_socket_read(), cherokee_socket_write(),
cherokee_socket_writev(), now errors which are not
logged lead to ret_error instead of ret_eof.

* cherokee/logger_writer.c:
- added a loop around write() in order to retry write()
in case of EINTR error (signal interrupt).

2007-01-22 Alvaro Lopez Ortega <alvaro@alobbs.com>

* cherokee/main.c (BASIC_CONFIG): iocache should be off in the
Expand Down
2 changes: 1 addition & 1 deletion cherokee/connection-protected.h
Expand Up @@ -199,7 +199,7 @@ ret_t cherokee_connection_mrproper (cherokee_connection_t *conn);

/* Close
*/
ret_t cherokee_connection_pre_lingering_close (cherokee_connection_t *conn);
ret_t cherokee_connection_shutdown_wr (cherokee_connection_t *conn);
ret_t cherokee_connection_linger_read (cherokee_connection_t *conn);

/* Connection I/O
Expand Down
22 changes: 10 additions & 12 deletions cherokee/connection.c
Expand Up @@ -326,17 +326,17 @@ cherokee_connection_clean (cherokee_connection_t *conn)
ret_t
cherokee_connection_mrproper (cherokee_connection_t *conn)
{
ret_t ret;

/* Close and clean socket, objects, etc.
* IGNORING ERRORS in order to not leave things
* in an uncleaned / undetermined state.
*/
conn->keepalive = 0;

/* Close and clean the socket
*/
ret = cherokee_socket_close (&conn->socket);
if (unlikely(ret < ret_ok)) return ret;
cherokee_socket_close (&conn->socket);

ret = cherokee_socket_clean (&conn->socket);
if (unlikely(ret < ret_ok)) return ret;
cherokee_socket_clean (&conn->socket);

/* Clean the connection object
*/
Expand All @@ -351,7 +351,6 @@ cherokee_connection_mrproper (cherokee_connection_t *conn)
}



ret_t
cherokee_connection_setup_error_handler (cherokee_connection_t *conn)
{
Expand Down Expand Up @@ -825,7 +824,7 @@ cherokee_connection_send (cherokee_connection_t *conn)


ret_t
cherokee_connection_pre_lingering_close (cherokee_connection_t *conn)
cherokee_connection_shutdown_wr (cherokee_connection_t *conn)
{
/* At this point, we don't want to follow the TLS protocol
* any longer.
Expand Down Expand Up @@ -1899,9 +1898,8 @@ cherokee_connection_log_or_delay (cherokee_connection_t *conn)
if (conn->log_at_end == 0) {
if (conn->logger_ref != NULL) {
if (http_type_400(conn->error_code) ||
http_type_500(conn->error_code))
{
ret = cherokee_logger_write_error (conn->logger_ref, conn);
http_type_500(conn->error_code)) {
ret = cherokee_logger_write_error (conn->logger_ref, conn);
} else {
ret = cherokee_logger_write_access (conn->logger_ref, conn);
}
Expand Down
9 changes: 7 additions & 2 deletions cherokee/logger_writer.c
Expand Up @@ -29,6 +29,8 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>

#ifdef HAVE_SYSLOG_H
Expand Down Expand Up @@ -253,8 +255,11 @@ cherokee_logger_writer_flush (cherokee_logger_writer_t *writer)

case cherokee_logger_writer_pipe:
case cherokee_logger_writer_file:
re = write (writer->fd, writer->buffer.buf, buflen);
if (re < 0) return ret_error;
do {
re = write (writer->fd, writer->buffer.buf, buflen);
} while (re == -1 && errno == EINTR);
if (re < 0)
return ret_error;

cherokee_buffer_move_to_begin (&writer->buffer, re);
if (! cherokee_buffer_is_empty (&writer->buffer))
Expand Down
20 changes: 16 additions & 4 deletions cherokee/socket.c
Expand Up @@ -907,12 +907,16 @@ cherokee_write (cherokee_socket_t *socket, const char *buf, int buf_len, size_t
case EAGAIN:
case EINTR:
return ret_eagain;

case EPIPE:
#ifdef ENOTCONN
case ENOTCONN:
#endif
case ETIMEDOUT:
case ECONNRESET:
case EHOSTUNREACH:
socket->status = socket_closed;
return ret_eof;
return ret_error;
}

PRINT_ERROR ("ERROR: write(%d, ..) -> errno=%d '%s'\n",
Expand Down Expand Up @@ -1012,14 +1016,18 @@ cherokee_read (cherokee_socket_t *socket, char *buf, int buf_size, size_t *done)
case EINTR:
case EAGAIN:
return ret_eagain;

case EBADF:
case EPIPE:
case ENOTSOCK:
#ifdef ENOTCONN
case ENOTCONN:
#endif
case ETIMEDOUT:
case ECONNRESET:
case EHOSTUNREACH:
socket->status = socket_closed;
return ret_eof;
return ret_error;
}

PRINT_ERROR ("ERROR: read(%d, ..) -> errno=%d '%s'\n",
Expand Down Expand Up @@ -1072,13 +1080,17 @@ cherokee_writev (cherokee_socket_t *socket, const struct iovec *vector, uint16_t
case EAGAIN:
case EINTR:
return ret_eagain;

case EPIPE:
#ifdef ENOTCONN
case ENOTCONN:
#endif
case ETIMEDOUT:
case ECONNRESET:
socket->status = socket_closed;
return ret_eof;
return ret_error;
}

PRINT_ERROR ("ERROR: writev(%d, ..) -> errno=%d '%s'\n",
SOCKET_FD(socket), err, strerror(err));
return ret_error;
Expand Down
6 changes: 3 additions & 3 deletions cherokee/thread.c
Expand Up @@ -443,7 +443,7 @@ purge_maybe_lingering (cherokee_thread_t *thread, cherokee_connection_t *conn)

/* Shutdown writing, and try to read some trash
*/
ret = cherokee_connection_pre_lingering_close (conn);
ret = cherokee_connection_shutdown_wr (conn);
switch (ret) {
case ret_ok:
case ret_eagain:
Expand Down Expand Up @@ -477,7 +477,7 @@ maybe_purge_closed_connection (cherokee_thread_t *thread, cherokee_connection_t
* cork before shutdown or before a close).
*/
if (conn->keepalive <= 0) {
ret = cherokee_connection_pre_lingering_close (conn);
ret = cherokee_connection_shutdown_wr (conn);
switch (ret) {
case ret_ok:
case ret_eagain:
Expand Down Expand Up @@ -1217,7 +1217,7 @@ process_active_connections (cherokee_thread_t *thd)

case phase_shutdown:

ret = cherokee_connection_pre_lingering_close (conn);
ret = cherokee_connection_shutdown_wr (conn);
switch (ret) {
case ret_ok:
case ret_eagain:
Expand Down

0 comments on commit 89220c0

Please sign in to comment.