2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
#include <ngx_config.h>
|
2002-08-30 00:59:54 +08:00
|
|
|
#include <ngx_core.h>
|
2002-08-07 00:39:45 +08:00
|
|
|
#include <ngx_types.h>
|
|
|
|
#include <ngx_connection.h>
|
|
|
|
#include <ngx_event_close.h>
|
|
|
|
|
|
|
|
|
2002-08-26 23:18:19 +08:00
|
|
|
int ngx_event_close_connection(ngx_event_t *ev)
|
2002-08-07 00:39:45 +08:00
|
|
|
{
|
|
|
|
int rc;
|
2002-08-30 00:59:54 +08:00
|
|
|
ngx_connection_t *c = (ngx_connection_t *) ev->data;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2002-08-30 00:59:54 +08:00
|
|
|
ngx_assert((c->fd != -1), return NGX_ERROR, c->log,
|
2002-08-07 00:39:45 +08:00
|
|
|
"ngx_event_close: already closed");
|
|
|
|
|
2002-08-30 00:59:54 +08:00
|
|
|
ngx_destroy_pool(c->pool);
|
|
|
|
|
|
|
|
if ((rc = ngx_close_socket(c->fd)) == -1)
|
|
|
|
ngx_log_error(NGX_LOG_ERR, c->log, ngx_socket_errno,
|
2002-08-07 00:39:45 +08:00
|
|
|
"ngx_event_close: close failed");
|
|
|
|
|
2002-08-30 00:59:54 +08:00
|
|
|
if (c->read->next)
|
|
|
|
ngx_del_event(c->read, NGX_READ_EVENT);
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2002-08-30 00:59:54 +08:00
|
|
|
if (c->write->next)
|
|
|
|
ngx_del_event(c->write, NGX_WRITE_EVENT);
|
2002-08-07 00:39:45 +08:00
|
|
|
|
2002-08-30 00:59:54 +08:00
|
|
|
c->fd = -1;
|
2002-08-07 00:39:45 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|