fixed quite some segmentation faults in http-thr.c.
similar fixes must be done on other task implementations such as http-file.c
This commit is contained in:
@ -848,7 +848,7 @@ static int print_qparam (hio_bcs_t* key, hio_bcs_t* val, void* ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_htts_thr_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
static void on_htts_thr_request (hio_svc_htts_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
int i;
|
int i;
|
||||||
|
10
bin/t06.c
10
bin/t06.c
@ -27,7 +27,7 @@ static int print_qparam (hio_bcs_t* key, hio_bcs_t* val, void* ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_htts_thr_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
static void on_htts_thr_request (hio_svc_htts_t* htts, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
||||||
{
|
{
|
||||||
FILE* fp;
|
FILE* fp;
|
||||||
int i;
|
int i;
|
||||||
@ -62,7 +62,7 @@ static void on_htts_thr_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_
|
|||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_htts_thr2_request (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
static void on_htts_thr2_request (hio_svc_htts_t* htts, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
||||||
{
|
{
|
||||||
FILE* fp, * sf;
|
FILE* fp, * sf;
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ int process_http_request (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
{
|
{
|
||||||
hio_t* hio = hio_svc_htts_gethio(htts);
|
hio_t* hio = hio_svc_htts_gethio(htts);
|
||||||
// hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(csck);
|
// hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(csck);
|
||||||
hio_http_method_t mth;
|
// hio_http_method_t mth;
|
||||||
|
|
||||||
/* percent-decode the query path to the original buffer
|
/* percent-decode the query path to the original buffer
|
||||||
* since i'm not going to need it in the original form
|
* since i'm not going to need it in the original form
|
||||||
@ -149,7 +149,7 @@ if (hio_htre_getcontentlen(req) > 0)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mth = hio_htre_getqmethodtype(req);
|
// mth = hio_htre_getqmethodtype(req);
|
||||||
/* determine what to do once the header fields are all received.
|
/* determine what to do once the header fields are all received.
|
||||||
* i don't want to delay this until the contents are received.
|
* i don't want to delay this until the contents are received.
|
||||||
* if you don't like this behavior, you must implement your own
|
* if you don't like this behavior, you must implement your own
|
||||||
@ -208,7 +208,7 @@ if (hio_htre_getcontentlen(req) > 0)
|
|||||||
{
|
{
|
||||||
hio_skad_t fcgis_addr;
|
hio_skad_t fcgis_addr;
|
||||||
hio_bcstrtoskad(hio, "127.0.0.1:9000", &fcgis_addr);
|
hio_bcstrtoskad(hio, "127.0.0.1:9000", &fcgis_addr);
|
||||||
x = hio_svc_htts_dofcgi(htts, csck, req, &fcgis_addr, 0);
|
x = hio_svc_htts_dofcgi(htts, csck, req, &fcgis_addr, "", qpath + 5, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain", 0, HIO_NULL);
|
x = hio_svc_htts_dofile(htts, csck, req, "", qpath, "text/plain", 0, HIO_NULL);
|
||||||
|
16
bin/webs.c
16
bin/webs.c
@ -51,15 +51,17 @@ static void untar_write_status_code (int fd, int code)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void untar (hio_t* hio, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
static void untar (hio_svc_htts_t* htts, hio_dev_thr_iopair_t* iop, hio_svc_htts_thr_func_info_t* tfi, void* ctx)
|
||||||
{
|
{
|
||||||
FILE* wfp = HIO_NULL;
|
FILE* wfp = HIO_NULL;
|
||||||
|
hio_t* hio;
|
||||||
htts_ext_t* ext;
|
htts_ext_t* ext;
|
||||||
hio_tar_t* tar = HIO_NULL;
|
hio_tar_t* tar = HIO_NULL;
|
||||||
hio_uint8_t buf[4096];
|
hio_uint8_t buf[4096];
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
ext = hio_svc_htts_getxtn(tfi->htts);
|
hio = hio_svc_htts_gethio(htts);
|
||||||
|
ext = hio_svc_htts_getxtn(htts);
|
||||||
|
|
||||||
/* TODO: error handling on write() failure */
|
/* TODO: error handling on write() failure */
|
||||||
wfp = fdopen(iop->wfd, "w");
|
wfp = fdopen(iop->wfd, "w");
|
||||||
@ -317,11 +319,19 @@ static int process_http_request (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_
|
|||||||
/* don't care about the path for now. TODO: make this secure and reasonable */
|
/* don't care about the path for now. TODO: make this secure and reasonable */
|
||||||
if (hio_svc_htts_dothr(htts, csck, req, untar, HIO_NULL, 0) <= -1) goto oops;
|
if (hio_svc_htts_dothr(htts, csck, req, untar, HIO_NULL, 0) <= -1) goto oops;
|
||||||
}
|
}
|
||||||
|
else if (mth == HIO_HTTP_OPTIONS)
|
||||||
|
{
|
||||||
|
//if (hio_svc_htts_dofun(htts, csck, req, options, HIO_NULL, 0) <= -1) goto oops;
|
||||||
|
}
|
||||||
else if (hio_comp_bcstr(qpath_ext, ".php", 0) == 0)
|
else if (hio_comp_bcstr(qpath_ext, ".php", 0) == 0)
|
||||||
{
|
{
|
||||||
hio_skad_t skad;
|
hio_skad_t skad;
|
||||||
hio_bcstrtoskad(hio, "10.30.0.133:9000", &skad);
|
hio_bcstrtoskad(hio, "10.30.0.133:9000", &skad);
|
||||||
if (hio_svc_htts_dofcgi(htts, csck, req, &skad, 0) <= -1) goto oops;
|
/*if (hio_svc_htts_dofcgi(htts, csck, req, &skad, ext->ai->docroot, qpath, 0) <= -1) goto oops;*/
|
||||||
|
/* if the document root is relative, it is hard to gurantee that the same document is
|
||||||
|
* true to the fcgi server which is a different process. so map it a blank string for now.
|
||||||
|
* TODO: accept a separate document root for the fcgi server and use it below */
|
||||||
|
if (hio_svc_htts_dofcgi(htts, csck, req, &skad, "", qpath, 0) <= -1) goto oops;
|
||||||
/*if (hio_svc_htts_dotxt(htts, csck, req, HIO_HTTP_STATUS_INTERNAL_SERVER_ERROR, "text/plain", "what the...", 0) <= -1) goto oops;*/
|
/*if (hio_svc_htts_dotxt(htts, csck, req, HIO_HTTP_STATUS_INTERNAL_SERVER_ERROR, "text/plain", "what the...", 0) <= -1) goto oops;*/
|
||||||
}
|
}
|
||||||
else // if (mth == HIO_HTTP_GET || mth == HIO_HTTP_POST)
|
else // if (mth == HIO_HTTP_GET || mth == HIO_HTTP_POST)
|
||||||
|
138
lib/fcgi-cli.c
138
lib/fcgi-cli.c
@ -46,6 +46,7 @@ struct hio_svc_fcgic_t
|
|||||||
|
|
||||||
struct hio_svc_fcgic_sess_t
|
struct hio_svc_fcgic_sess_t
|
||||||
{
|
{
|
||||||
|
int active;
|
||||||
hio_oow_t sid;
|
hio_oow_t sid;
|
||||||
hio_svc_fcgic_conn_t* conn;
|
hio_svc_fcgic_conn_t* conn;
|
||||||
hio_svc_fcgic_on_read_t on_read;
|
hio_svc_fcgic_on_read_t on_read;
|
||||||
@ -65,20 +66,29 @@ struct hio_svc_fcgic_conn_t
|
|||||||
hio_oow_t free; /* the index to the first free session slot */
|
hio_oow_t free; /* the index to the first free session slot */
|
||||||
} sess;
|
} sess;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
R_AWAITING_HEADER,
|
||||||
|
R_AWAITING_BODY
|
||||||
|
} state;
|
||||||
|
|
||||||
|
hio_uint8_t type;
|
||||||
|
hio_uint16_t id;
|
||||||
|
hio_uint16_t content_len;
|
||||||
|
hio_uint8_t padding_len;
|
||||||
|
|
||||||
|
hio_uint8_t buf[1024]; /* TODO: make it smaller... */
|
||||||
|
hio_oow_t len;
|
||||||
|
} r; /* space to parse incoming reply header */
|
||||||
|
|
||||||
hio_svc_fcgic_conn_t* next;
|
hio_svc_fcgic_conn_t* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fcgic_sck_xtn_t
|
struct fcgic_sck_xtn_t
|
||||||
{
|
{
|
||||||
hio_svc_fcgic_conn_t* conn;
|
hio_svc_fcgic_conn_t* conn;
|
||||||
#if 0
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
hio_uint8_t* ptr;
|
|
||||||
hio_oow_t len;
|
|
||||||
hio_oow_t capa;
|
|
||||||
} rbuf; /* used by tcp socket */
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
typedef struct fcgic_sck_xtn_t fcgic_sck_xtn_t;
|
typedef struct fcgic_sck_xtn_t fcgic_sck_xtn_t;
|
||||||
|
|
||||||
@ -111,6 +121,7 @@ typedef struct fcgic_fcgi_msg_xtn_t fcgic_fcgi_msg_xtn_t;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int make_connection_socket (hio_svc_fcgic_conn_t* conn);
|
static int make_connection_socket (hio_svc_fcgic_conn_t* conn);
|
||||||
|
static void release_session (hio_svc_fcgic_sess_t* sess);
|
||||||
|
|
||||||
static void sck_on_disconnect (hio_dev_sck_t* sck)
|
static void sck_on_disconnect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
@ -130,6 +141,18 @@ printf ("DISCONNECT SOCKET .................. sck->%p conn->%p\n", sck, conn);
|
|||||||
make_connection_socket(conn); /* don't care about failure for now */
|
make_connection_socket(conn); /* don't care about failure for now */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
hio_oow_t i;
|
||||||
|
for (i = 0; i < conn->sess.capa; i++)
|
||||||
|
{
|
||||||
|
hio_svc_fcgic_sess_t* sess;
|
||||||
|
sess = &conn->sess.ptr[i + 1];
|
||||||
|
if (sess->active)
|
||||||
|
{
|
||||||
|
/* TODO: release the session???*/
|
||||||
|
release_session (sess); /* TODO: is this correct?? */
|
||||||
|
/* or do we fire a callback??? */
|
||||||
|
}
|
||||||
|
}
|
||||||
conn->dev = HIO_NULL;
|
conn->dev = HIO_NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -137,7 +160,14 @@ printf ("DISCONNECT SOCKET .................. sck->%p conn->%p\n", sck, conn);
|
|||||||
|
|
||||||
static void sck_on_connect (hio_dev_sck_t* sck)
|
static void sck_on_connect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
printf ("CONNECTED >>>>>>>>>>>>>>>>>>>>>>>>>>\n");
|
fcgic_sck_xtn_t* sck_xtn = hio_dev_sck_getxtn(sck);
|
||||||
|
hio_svc_fcgic_conn_t* conn = sck_xtn->conn;
|
||||||
|
|
||||||
|
printf ("CONNECTED >>>>>>>>>>>>>>>>>>>>>>>>>>\n");
|
||||||
|
|
||||||
|
/* reinitialize the input parsing information */
|
||||||
|
HIO_MEMSET (&conn->r, 0, HIO_SIZEOF(conn->r));
|
||||||
|
conn->r.state = R_AWAITING_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sck_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
|
static int sck_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
|
||||||
@ -145,23 +175,91 @@ static int sck_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, con
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sck_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
|
static int sck_on_read (hio_dev_sck_t* sck, const void* data, hio_iolen_t dlen, const hio_skad_t* srcaddr)
|
||||||
{
|
{
|
||||||
fcgic_sck_xtn_t* sck_xtn = hio_dev_sck_getxtn(sck);
|
fcgic_sck_xtn_t* sck_xtn = hio_dev_sck_getxtn(sck);
|
||||||
hio_svc_fcgic_conn_t* conn = sck_xtn->conn;
|
hio_svc_fcgic_conn_t* conn = sck_xtn->conn;
|
||||||
|
hio_t* hio = conn->fcgic->hio;
|
||||||
|
|
||||||
if (len == 0)
|
if (dlen <= -1)
|
||||||
{
|
{
|
||||||
|
/* error or timeout */
|
||||||
|
/* fire all related fcgi sessions?? -> handled on disconnect */
|
||||||
|
}
|
||||||
|
else if (dlen == 0)
|
||||||
|
{
|
||||||
|
/* EOF */
|
||||||
hio_dev_sck_halt (sck);
|
hio_dev_sck_halt (sck);
|
||||||
|
/* fire all related fcgi sessions?? -> handled on disconnect?? */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO: parse the reply ..*/
|
do
|
||||||
|
{
|
||||||
|
if (conn->r.state == R_AWAITING_HEADER)
|
||||||
|
{
|
||||||
|
hio_fcgi_record_header_t* h;
|
||||||
|
hio_iolen_t reqlen, cplen;
|
||||||
|
HIO_ASSERT (hio, conn->r.len < HIO_SIZEOF(*h));
|
||||||
|
|
||||||
/*sess = get_session(using the session id);*/
|
reqlen = HIO_SIZEOF(*h) - conn->r.len;
|
||||||
/*sess->on_read (sess, ptr, len);*/
|
cplen = (dlen > reqlen)? reqlen: dlen;
|
||||||
|
HIO_MEMCPY (&conn->r.buf[conn->r.len], data, cplen);
|
||||||
|
conn->r.len += cplen;
|
||||||
|
|
||||||
|
data += cplen;
|
||||||
|
dlen -= cplen;
|
||||||
|
|
||||||
|
if (conn->r.len < HIO_SIZEOF(*h))
|
||||||
|
{
|
||||||
|
/* not enough data to complete a header*/
|
||||||
|
HIO_ASSERT (hio, dlen == 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h = (hio_fcgi_record_header_t*)conn->r.buf;
|
||||||
|
conn->r.type = h->type;
|
||||||
|
conn->r.id = hio_ntoh16(h->id);
|
||||||
|
conn->r.content_len = hio_ntoh16(h->content_len);
|
||||||
|
conn->r.padding_len = hio_ntoh16(h->padding_len);
|
||||||
|
conn->r.len = 0;
|
||||||
|
conn->r.state == R_AWAITING_BODY;
|
||||||
|
}
|
||||||
|
else /* R_AWAITING_BODY */
|
||||||
|
{
|
||||||
|
switch (conn->r.type)
|
||||||
|
{
|
||||||
|
case HIO_FCGI_END_REQUEST:
|
||||||
|
|
||||||
|
case HIO_FCGI_STDOUT:
|
||||||
|
case HIO_FCGI_STDERR:
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* discard the record */
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (conn->r.id >= 1 && conn->r.id <= conn->sess.capa)
|
||||||
|
{
|
||||||
|
hio_svc_fcgic_sess_t* sess;
|
||||||
|
sess = &conn->sess.ptr[conn->r.id - 1];
|
||||||
|
if (sess->active)
|
||||||
|
{
|
||||||
|
sess->on_read (sess, data, dlen);
|
||||||
|
/* TODO: return code check??? */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* invalid sid */
|
||||||
|
/* TODO: logging or something*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (dlen > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +316,7 @@ static int make_connection_socket (hio_svc_fcgic_conn_t* conn)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf ("MAKING CONNECTION %p %p\n", conn->dev, sck);
|
printf ("MAKING CONNECTION %p %p\n", conn->dev, sck);
|
||||||
HIO_ASSERT (hio, conn->dev == HIO_NULL);
|
HIO_ASSERT (hio, conn->dev == HIO_NULL);
|
||||||
|
|
||||||
conn->dev = sck;
|
conn->dev = sck;
|
||||||
@ -238,6 +336,7 @@ static hio_svc_fcgic_conn_t* get_connection (hio_svc_fcgic_t* fcgic, const hio_s
|
|||||||
if (conn->sess.free != INVALID_SID ||
|
if (conn->sess.free != INVALID_SID ||
|
||||||
conn->sess.capa <= (CONN_SESS_CAPA_MAX - CONN_SESS_INC))
|
conn->sess.capa <= (CONN_SESS_CAPA_MAX - CONN_SESS_INC))
|
||||||
{
|
{
|
||||||
|
/* the connection has room for more sessions */
|
||||||
if (!conn->dev) make_connection_socket(conn); /* conn->dev will still be null if connection fails*/
|
if (!conn->dev) make_connection_socket(conn); /* conn->dev will still be null if connection fails*/
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
@ -307,6 +406,8 @@ static hio_svc_fcgic_sess_t* new_session (hio_svc_fcgic_t* fcgic, const hio_skad
|
|||||||
|
|
||||||
for (i = conn->sess.capa ; i < newcapa; i++)
|
for (i = conn->sess.capa ; i < newcapa; i++)
|
||||||
{
|
{
|
||||||
|
/* management records use 0 for requestId.
|
||||||
|
* but application records have a nonzero requestId. */
|
||||||
newptr[i].sid = i + 1;
|
newptr[i].sid = i + 1;
|
||||||
newptr[i].conn = conn;
|
newptr[i].conn = conn;
|
||||||
}
|
}
|
||||||
@ -322,6 +423,7 @@ static hio_svc_fcgic_sess_t* new_session (hio_svc_fcgic_t* fcgic, const hio_skad
|
|||||||
|
|
||||||
sess->sid = conn->sess.free;
|
sess->sid = conn->sess.free;
|
||||||
sess->on_read = on_read;
|
sess->on_read = on_read;
|
||||||
|
sess->active = 1;
|
||||||
HIO_ASSERT (hio, sess->conn == conn);
|
HIO_ASSERT (hio, sess->conn == conn);
|
||||||
HIO_ASSERT (hio, sess->conn->fcgic == fcgic);
|
HIO_ASSERT (hio, sess->conn->fcgic == fcgic);
|
||||||
|
|
||||||
@ -330,6 +432,7 @@ static hio_svc_fcgic_sess_t* new_session (hio_svc_fcgic_t* fcgic, const hio_skad
|
|||||||
|
|
||||||
static void release_session (hio_svc_fcgic_sess_t* sess)
|
static void release_session (hio_svc_fcgic_sess_t* sess)
|
||||||
{
|
{
|
||||||
|
sess->active = 0;
|
||||||
sess->sid = sess->conn->sess.free;
|
sess->sid = sess->conn->sess.free;
|
||||||
sess->conn->sess.free = sess->sid;
|
sess->conn->sess.free = sess->sid;
|
||||||
}
|
}
|
||||||
@ -370,6 +473,8 @@ void hio_svc_fcgic_stop (hio_svc_fcgic_t* fcgic)
|
|||||||
|
|
||||||
HIO_SVCL_UNLINK_SVC (fcgic);
|
HIO_SVCL_UNLINK_SVC (fcgic);
|
||||||
hio_freemem (hio, fcgic);
|
hio_freemem (hio, fcgic);
|
||||||
|
|
||||||
|
HIO_DEBUG1 (hio, "FCGIC - STOPPED SERVICE %p\n", fcgic);
|
||||||
}
|
}
|
||||||
|
|
||||||
hio_svc_fcgic_sess_t* hio_svc_fcgic_tie (hio_svc_fcgic_t* fcgic, const hio_skad_t* addr, hio_svc_fcgic_on_read_t on_read)
|
hio_svc_fcgic_sess_t* hio_svc_fcgic_tie (hio_svc_fcgic_t* fcgic, const hio_skad_t* addr, hio_svc_fcgic_on_read_t on_read)
|
||||||
@ -429,6 +534,9 @@ int hio_svc_fcgic_writeparam (hio_svc_fcgic_sess_t* sess, const void* key, hio_i
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: buffer key value pairs. flush on the end of param of buffer full.
|
||||||
|
* can merge multipl key values pairs in one FCGI_PARAMS packets....
|
||||||
|
*/
|
||||||
HIO_MEMSET (&h, 0, HIO_SIZEOF(h));
|
HIO_MEMSET (&h, 0, HIO_SIZEOF(h));
|
||||||
h.version = HIO_FCGI_VERSION;
|
h.version = HIO_FCGI_VERSION;
|
||||||
h.type = HIO_FCGI_PARAMS;
|
h.type = HIO_FCGI_PARAMS;
|
||||||
|
@ -98,8 +98,8 @@ struct hio_svc_htts_rsrc_t
|
|||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_RSRC_HEADER;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HIO_SVC_HTTS_RSRC_ATTACH(rsrc, var) do { (var) = (rsrc); ++(rsrc)->rsrc_refcnt; } while(0)
|
#define HIO_SVC_HTTS_RSRC_REF(rsrc, var) do { (var) = (rsrc); ++(rsrc)->rsrc_refcnt; } while(0)
|
||||||
#define HIO_SVC_HTTS_RSRC_DETACH(rsrc_var) do { if (--(rsrc_var)->rsrc_refcnt == 0) { hio_svc_htts_rsrc_t* __rsrc_tmp = (rsrc_var); (rsrc_var) = HIO_NULL; hio_svc_htts_rsrc_kill(__rsrc_tmp); } else { (rsrc_var) = HIO_NULL; } } while(0)
|
#define HIO_SVC_HTTS_RSRC_UNREF(rsrc_var) do { if (--(rsrc_var)->rsrc_refcnt == 0) { hio_svc_htts_rsrc_t* __rsrc_tmp = (rsrc_var); (rsrc_var) = HIO_NULL; hio_svc_htts_rsrc_kill(__rsrc_tmp); } else { (rsrc_var) = HIO_NULL; } } while(0)
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@ -113,8 +113,6 @@ typedef int (*hio_svc_htts_proc_req_t) (
|
|||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
struct hio_svc_htts_thr_func_info_t
|
struct hio_svc_htts_thr_func_info_t
|
||||||
{
|
{
|
||||||
hio_svc_htts_t* htts;
|
|
||||||
|
|
||||||
hio_http_method_t req_method;
|
hio_http_method_t req_method;
|
||||||
hio_http_version_t req_version;
|
hio_http_version_t req_version;
|
||||||
hio_bch_t* req_path;
|
hio_bch_t* req_path;
|
||||||
@ -129,7 +127,7 @@ struct hio_svc_htts_thr_func_info_t
|
|||||||
typedef struct hio_svc_htts_thr_func_info_t hio_svc_htts_thr_func_info_t;
|
typedef struct hio_svc_htts_thr_func_info_t hio_svc_htts_thr_func_info_t;
|
||||||
|
|
||||||
typedef void (*hio_svc_htts_thr_func_t) (
|
typedef void (*hio_svc_htts_thr_func_t) (
|
||||||
hio_t* hio,
|
hio_svc_htts_t* htts,
|
||||||
hio_dev_thr_iopair_t* iop,
|
hio_dev_thr_iopair_t* iop,
|
||||||
hio_svc_htts_thr_func_info_t* tfi,
|
hio_svc_htts_thr_func_info_t* tfi,
|
||||||
void* ctx
|
void* ctx
|
||||||
@ -137,6 +135,28 @@ typedef void (*hio_svc_htts_thr_func_t) (
|
|||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
|
struct hio_svc_htts_fun_func_info_t
|
||||||
|
{
|
||||||
|
hio_http_method_t req_method;
|
||||||
|
hio_http_version_t req_version;
|
||||||
|
hio_bch_t* req_path;
|
||||||
|
hio_bch_t* req_param;
|
||||||
|
int req_x_http_method_override; /* -1 or hio_http_method_t */
|
||||||
|
|
||||||
|
/* TODO: header table */
|
||||||
|
|
||||||
|
hio_skad_t client_addr;
|
||||||
|
hio_skad_t server_addr;
|
||||||
|
};
|
||||||
|
typedef struct hio_svc_htts_fun_func_info_t hio_svc_htts_fun_func_info_t;
|
||||||
|
|
||||||
|
typedef void (*hio_svc_htts_fun_func_t) (
|
||||||
|
hio_svc_htts_t* htts,
|
||||||
|
void* ctx
|
||||||
|
);
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
enum hio_svc_htts_cgi_option_t
|
enum hio_svc_htts_cgi_option_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_CGI_NO_100_CONTINUE = (1 << 0)
|
HIO_SVC_HTTS_CGI_NO_100_CONTINUE = (1 << 0)
|
||||||
@ -302,6 +322,7 @@ HIO_EXPORT hio_oow_t hio_escape_html_bcstr (
|
|||||||
hio_bch_t* buf,
|
hio_bch_t* buf,
|
||||||
hio_oow_t len
|
hio_oow_t len
|
||||||
);
|
);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
/* HTTP SERVER SERVICE */
|
/* HTTP SERVER SERVICE */
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
@ -373,6 +394,8 @@ HIO_EXPORT int hio_svc_htts_dofcgi (
|
|||||||
hio_dev_sck_t* csck,
|
hio_dev_sck_t* csck,
|
||||||
hio_htre_t* req,
|
hio_htre_t* req,
|
||||||
const hio_skad_t* fcgis_addr,
|
const hio_skad_t* fcgis_addr,
|
||||||
|
const hio_bch_t* docroot,
|
||||||
|
const hio_bch_t* script,
|
||||||
int options /**< 0 or bitwise-Ored of #hio_svc_htts_file_option_t enumerators */
|
int options /**< 0 or bitwise-Ored of #hio_svc_htts_file_option_t enumerators */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1049,7 +1049,9 @@ int hio_htrd_feed (hio_htrd_t* htrd, const hio_bch_t* req, hio_oow_t len, hio_oo
|
|||||||
{
|
{
|
||||||
const hio_bch_t* end = req + len;
|
const hio_bch_t* end = req + len;
|
||||||
const hio_bch_t* ptr = req;
|
const hio_bch_t* ptr = req;
|
||||||
|
#if 0
|
||||||
int header_completed_during_this_feed = 0;
|
int header_completed_during_this_feed = 0;
|
||||||
|
#endif
|
||||||
hio_oow_t avail;
|
hio_oow_t avail;
|
||||||
|
|
||||||
HIO_ASSERT (htrd->hio, len > 0);
|
HIO_ASSERT (htrd->hio, len > 0);
|
||||||
@ -1153,8 +1155,10 @@ int hio_htrd_feed (hio_htrd_t* htrd, const hio_bch_t* req, hio_oow_t len, hio_oo
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* compelete request header is received */
|
/* compelete request header is received */
|
||||||
header_completed_during_this_feed = 1;
|
header_completed_during_this_feed = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if (htrd->recbs.peek(htrd, &htrd->re) <= -1)
|
if (htrd->recbs.peek(htrd, &htrd->re) <= -1)
|
||||||
|
@ -234,7 +234,7 @@ static HIO_INLINE void cgi_mark_over (cgi_t* cgi, int over_bits)
|
|||||||
HIO_ASSERT (cgi->htts->hio, cgi->client->rsrc == (hio_svc_htts_rsrc_t*)cgi);
|
HIO_ASSERT (cgi->htts->hio, cgi->client->rsrc == (hio_svc_htts_rsrc_t*)cgi);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", cgi->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", cgi->client->rsrc);*/
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (cgi->client->rsrc);
|
HIO_SVC_HTTS_RSRC_UNREF (cgi->client->rsrc);
|
||||||
/* cgi must not be accessed from here down as it could have been destroyed */
|
/* cgi must not be accessed from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -246,8 +246,9 @@ static HIO_INLINE void cgi_mark_over (cgi_t* cgi, int over_bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cgi_on_kill (cgi_t* cgi)
|
static void cgi_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
||||||
{
|
{
|
||||||
|
cgi_t* cgi = (cgi_t*)rsrc;
|
||||||
hio_t* hio = cgi->htts->hio;
|
hio_t* hio = cgi->htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - killing cgi client(%p)\n", cgi->htts, cgi->client->sck);
|
HIO_DEBUG2 (hio, "HTTS(%p) - killing cgi client(%p)\n", cgi->htts, cgi->client->sck);
|
||||||
@ -323,7 +324,7 @@ static void peer_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
|
|||||||
|
|
||||||
HIO_ASSERT (hio, peer_xtn->cgi != HIO_NULL);
|
HIO_ASSERT (hio, peer_xtn->cgi != HIO_NULL);
|
||||||
/*printf ("DETACHING FROM CGI PEER DEVICE.....................%p %d\n", peer->cgi, (int)peer->cgi->rsrc_refcnt);*/
|
/*printf ("DETACHING FROM CGI PEER DEVICE.....................%p %d\n", peer->cgi, (int)peer->cgi->rsrc_refcnt);*/
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (peer_xtn->cgi);
|
HIO_SVC_HTTS_RSRC_UNREF (peer_xtn->cgi);
|
||||||
|
|
||||||
if (cgi->peer_htrd)
|
if (cgi->peer_htrd)
|
||||||
{
|
{
|
||||||
@ -332,7 +333,7 @@ static void peer_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
|
|||||||
peer_xtn = hio_htrd_getxtn(cgi->peer_htrd);
|
peer_xtn = hio_htrd_getxtn(cgi->peer_htrd);
|
||||||
HIO_ASSERT (hio, peer_xtn->cgi != HIO_NULL);
|
HIO_ASSERT (hio, peer_xtn->cgi != HIO_NULL);
|
||||||
/*printf ("DETACHING FROM CGI PEER HTRD.....................%p %d\n", peer->cgi, (int)peer->cgi->rsrc_refcnt);*/
|
/*printf ("DETACHING FROM CGI PEER HTRD.....................%p %d\n", peer->cgi, (int)peer->cgi->rsrc_refcnt);*/
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (peer_xtn->cgi);
|
HIO_SVC_HTTS_RSRC_UNREF (peer_xtn->cgi);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -973,7 +974,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
csck->on_disconnect = cgi_client_on_disconnect;
|
csck->on_disconnect = cgi_client_on_disconnect;
|
||||||
|
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)cgi, cli->rsrc); /* cli->rsrc = cgi */
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)cgi, cli->rsrc); /* cli->rsrc = cgi */
|
||||||
|
|
||||||
if (access(mi.cmd, X_OK) == -1)
|
if (access(mi.cmd, X_OK) == -1)
|
||||||
{
|
{
|
||||||
@ -984,7 +985,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
cgi->peer = hio_dev_pro_make(hio, HIO_SIZEOF(*peer_xtn), &mi);
|
cgi->peer = hio_dev_pro_make(hio, HIO_SIZEOF(*peer_xtn), &mi);
|
||||||
if (HIO_UNLIKELY(!cgi->peer)) goto oops;
|
if (HIO_UNLIKELY(!cgi->peer)) goto oops;
|
||||||
peer_xtn = hio_dev_pro_getxtn(cgi->peer);
|
peer_xtn = hio_dev_pro_getxtn(cgi->peer);
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in pro = cgi */
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in pro = cgi */
|
||||||
|
|
||||||
cgi->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*peer_xtn));
|
cgi->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*peer_xtn));
|
||||||
if (HIO_UNLIKELY(!cgi->peer_htrd)) goto oops;
|
if (HIO_UNLIKELY(!cgi->peer_htrd)) goto oops;
|
||||||
@ -992,7 +993,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
hio_htrd_setrecbs (cgi->peer_htrd, &peer_htrd_recbs);
|
hio_htrd_setrecbs (cgi->peer_htrd, &peer_htrd_recbs);
|
||||||
|
|
||||||
peer_xtn = hio_htrd_getxtn(cgi->peer_htrd);
|
peer_xtn = hio_htrd_getxtn(cgi->peer_htrd);
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in htrd = cgi */
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in htrd = cgi */
|
||||||
|
|
||||||
#if !defined(CGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
#if !defined(CGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||||
if (cgi->req_content_length_unlimited)
|
if (cgi->req_content_length_unlimited)
|
||||||
|
@ -163,7 +163,7 @@ printf (">>>>>>>>>>>> disableing client read watching ...................\n");
|
|||||||
HIO_ASSERT (fcgi->htts->hio, fcgi->client->rsrc == (hio_svc_htts_rsrc_t*)fcgi);
|
HIO_ASSERT (fcgi->htts->hio, fcgi->client->rsrc == (hio_svc_htts_rsrc_t*)fcgi);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", fcgi->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", fcgi->client->rsrc);*/
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (fcgi->client->rsrc);
|
HIO_SVC_HTTS_RSRC_UNREF (fcgi->client->rsrc);
|
||||||
/* fcgi must not be accessed from here down as it could have been destroyed */
|
/* fcgi must not be accessed from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -371,8 +371,9 @@ printf ("GOT FCGI DATA.............[%.*s]\n", (int)len, buf);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fcgi_on_kill (fcgi_t* fcgi)
|
static void fcgi_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
||||||
{
|
{
|
||||||
|
fcgi_t* fcgi = (fcgi_t*)rsrc;
|
||||||
hio_t* hio = fcgi->htts->hio;
|
hio_t* hio = fcgi->htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - killing fcgi client(%p)\n", fcgi->htts, fcgi->client->sck);
|
HIO_DEBUG2 (hio, "HTTS(%p) - killing fcgi client(%p)\n", fcgi->htts, fcgi->client->sck);
|
||||||
@ -422,25 +423,29 @@ static void fcgi_on_kill (fcgi_t* fcgi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_params (fcgi_t* fcgi, hio_dev_sck_t* csck, hio_htre_t* req)
|
static int write_params (fcgi_t* fcgi, hio_dev_sck_t* csck, hio_htre_t* req, const hio_bch_t* docroot, const hio_bch_t* script)
|
||||||
{
|
{
|
||||||
hio_t* hio = fcgi->htts->hio;
|
hio_t* hio = fcgi->htts->hio;
|
||||||
hio_bch_t tmp[256];
|
hio_bch_t tmp[256];
|
||||||
hio_oow_t len;
|
hio_oow_t len;
|
||||||
const hio_bch_t* qparam;
|
const hio_bch_t* qparam;
|
||||||
hio_oow_t content_length;
|
hio_oow_t content_length;
|
||||||
|
hio_bch_t* actual_script = HIO_NULL;
|
||||||
|
|
||||||
HIO_ASSERT (hio, fcgi->client->sck == csck);
|
HIO_ASSERT (hio, fcgi->client->sck == csck);
|
||||||
|
|
||||||
|
actual_script = hio_svc_htts_dupmergepaths(fcgi->htts, docroot, script);
|
||||||
|
if (!actual_script) goto oops;
|
||||||
|
|
||||||
if (hio_svc_fcgic_writeparam(fcgi->peer, "GATEWAY_INTERFACE", 17, "CGI/1.1", 7) <= -1) goto oops;
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "GATEWAY_INTERFACE", 17, "CGI/1.1", 7) <= -1) goto oops;
|
||||||
|
|
||||||
len = hio_fmttobcstr(hio, tmp, HIO_COUNTOF(tmp), "HTTP/%d.%d", (int)hio_htre_getmajorversion(req), (int)hio_htre_getminorversion(req));
|
len = hio_fmttobcstr(hio, tmp, HIO_COUNTOF(tmp), "HTTP/%d.%d", (int)hio_htre_getmajorversion(req), (int)hio_htre_getminorversion(req));
|
||||||
if (hio_svc_fcgic_writeparam(fcgi->peer, "SERVER_PROTOCOL", 15, tmp, len) <= -1) goto oops;
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "SERVER_PROTOCOL", 15, tmp, len) <= -1) goto oops;
|
||||||
|
|
||||||
// TODOs:
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "DOCUMENT_ROOT", 13, docroot, hio_count_bcstr(docroot)) <= -1) goto oops;
|
||||||
// DOCUMENT_ROOT
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "SCRIPT_NAME", 11, script, hio_count_bcstr(script)) <= -1) goto oops;
|
||||||
// SCRIPT_NAME
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "SCRIPT_FILENAME", 15, actual_script, hio_count_bcstr(actual_script)) <= -1) goto oops;
|
||||||
// PATH_INFO
|
// TODO: PATH_INFO
|
||||||
|
|
||||||
if (hio_svc_fcgic_writeparam(fcgi->peer, "REQUEST_METHOD", 14, hio_htre_getqmethodname(req), hio_htre_getqmethodlen(req)) <= -1) goto oops;
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "REQUEST_METHOD", 14, hio_htre_getqmethodname(req), hio_htre_getqmethodlen(req)) <= -1) goto oops;
|
||||||
if (hio_svc_fcgic_writeparam(fcgi->peer, "REQUEST_URI", 11, hio_htre_getqpath(req), hio_htre_getqpathlen(req)) <= -1) goto oops;
|
if (hio_svc_fcgic_writeparam(fcgi->peer, "REQUEST_URI", 11, hio_htre_getqpath(req), hio_htre_getqpathlen(req)) <= -1) goto oops;
|
||||||
@ -477,9 +482,10 @@ static int write_params (fcgi_t* fcgi, hio_dev_sck_t* csck, hio_htre_t* req)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
oops:
|
oops:
|
||||||
|
if (actual_script) hio_freemem (hio, actual_script);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* req, const hio_skad_t* fcgis_addr, int options)
|
int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* req, const hio_skad_t* fcgis_addr, const hio_bch_t* docroot, const hio_bch_t* script, int options)
|
||||||
{
|
{
|
||||||
hio_t* hio = htts->hio;
|
hio_t* hio = htts->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(csck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(csck);
|
||||||
@ -514,7 +520,7 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
csck->on_disconnect = fcgi_client_on_disconnect;
|
csck->on_disconnect = fcgi_client_on_disconnect;
|
||||||
|
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)fcgi, cli->rsrc); /* cli->rsrc = fcgi */
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)fcgi, cli->rsrc); /* cli->rsrc = fcgi */
|
||||||
|
|
||||||
/* create a session in in the fcgi client service */
|
/* create a session in in the fcgi client service */
|
||||||
fcgi->peer = hio_svc_fcgic_tie(htts->fcgic, fcgis_addr, fcgi_peer_on_read);
|
fcgi->peer = hio_svc_fcgic_tie(htts->fcgic, fcgis_addr, fcgi_peer_on_read);
|
||||||
@ -523,7 +529,7 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
/* send FCGI_BEGIN_REQUEST */
|
/* send FCGI_BEGIN_REQUEST */
|
||||||
if (hio_svc_fcgic_beginrequest(fcgi->peer) <= -1) goto oops;
|
if (hio_svc_fcgic_beginrequest(fcgi->peer) <= -1) goto oops;
|
||||||
/* write FCGI_PARAM */
|
/* write FCGI_PARAM */
|
||||||
if (write_params(fcgi, csck, req) <= -1) goto oops;
|
if (write_params(fcgi, csck, req, docroot, script) <= -1) goto oops;
|
||||||
if (hio_svc_fcgic_writeparam(fcgi->peer, HIO_NULL, 0, HIO_NULL, 0) <= -1) goto oops; /* end of params */
|
if (hio_svc_fcgic_writeparam(fcgi->peer, HIO_NULL, 0, HIO_NULL, 0) <= -1) goto oops; /* end of params */
|
||||||
|
|
||||||
#if !defined(FCGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
#if !defined(FCGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||||
|
@ -227,7 +227,7 @@ static void file_mark_over (file_t* file, int over_bits)
|
|||||||
|
|
||||||
/* how to arrange to delete this file object and put the socket back to the normal waiting state??? */
|
/* how to arrange to delete this file object and put the socket back to the normal waiting state??? */
|
||||||
HIO_ASSERT (file->htts->hio, file->client->rsrc == (hio_svc_htts_rsrc_t*)file);
|
HIO_ASSERT (file->htts->hio, file->client->rsrc == (hio_svc_htts_rsrc_t*)file);
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (file->client->rsrc);
|
HIO_SVC_HTTS_RSRC_UNREF (file->client->rsrc);
|
||||||
/* the file resource must not be accessed from here down as it could have been destroyed */
|
/* the file resource must not be accessed from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -242,7 +242,7 @@ static void file_mark_over (file_t* file, int over_bits)
|
|||||||
|
|
||||||
static int file_write_to_peer (file_t* file, const void* data, hio_iolen_t dlen)
|
static int file_write_to_peer (file_t* file, const void* data, hio_iolen_t dlen)
|
||||||
{
|
{
|
||||||
hio_t* hio = file->htts->hio;
|
/* hio_t* hio = file->htts->hio; */
|
||||||
|
|
||||||
if (dlen <= 0)
|
if (dlen <= 0)
|
||||||
{
|
{
|
||||||
@ -269,8 +269,9 @@ static int file_write_to_peer (file_t* file, const void* data, hio_iolen_t dlen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void file_on_kill (file_t* file)
|
static void file_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
||||||
{
|
{
|
||||||
|
file_t* file = (file_t*)rsrc;
|
||||||
hio_t* hio = file->htts->hio;
|
hio_t* hio = file->htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG3 (hio, "HTTS(%p) - file(c=%d,p=%d) on_kill\n", file->htts, (int)file->client->sck->hnd, file->peer);
|
HIO_DEBUG3 (hio, "HTTS(%p) - file(c=%d,p=%d) on_kill\n", file->htts, (int)file->client->sck->hnd, file->peer);
|
||||||
@ -810,7 +811,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
file->peer = -1;
|
file->peer = -1;
|
||||||
|
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL); /* you must not call this function while cli->rsrc is not HIO_NULL */
|
HIO_ASSERT (hio, cli->rsrc == HIO_NULL); /* you must not call this function while cli->rsrc is not HIO_NULL */
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)file, cli->rsrc); /* cli->rsrc = file with ref-count up */
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)file, cli->rsrc); /* cli->rsrc = file with ref-count up */
|
||||||
|
|
||||||
|
|
||||||
#if !defined(FILE_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
#if !defined(FILE_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||||
@ -843,7 +844,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
else if (req->flags & HIO_HTRE_ATTR_EXPECT)
|
else if (req->flags & HIO_HTRE_ATTR_EXPECT)
|
||||||
{
|
{
|
||||||
/* 417 Expectation Failed */
|
/* 417 Expectation Failed */
|
||||||
file_send_final_status_to_client (file, HIO_HTTP_STATUS_EXPECTATION_FAILED, 1, HIO_NULL);
|
file_send_final_status_to_client (file, HIO_HTTP_STATUS_EXPECTATION_FAILED, 1, 0);
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ struct hio_svc_httc_t
|
|||||||
HIO_SVC_HEADER;
|
HIO_SVC_HEADER;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* client list */
|
||||||
#define HIO_SVC_HTTS_CLIL_APPEND_CLI(lh,cli) do { \
|
#define HIO_SVC_HTTS_CLIL_APPEND_CLI(lh,cli) do { \
|
||||||
(cli)->cli_next = (lh); \
|
(cli)->cli_next = (lh); \
|
||||||
(cli)->cli_prev = (lh)->cli_prev; \
|
(cli)->cli_prev = (lh)->cli_prev; \
|
||||||
|
@ -100,16 +100,11 @@ oops:
|
|||||||
|
|
||||||
static void fini_client (hio_svc_htts_cli_t* cli)
|
static void fini_client (hio_svc_htts_cli_t* cli)
|
||||||
{
|
{
|
||||||
HIO_DEBUG4 (cli->sck->hio, "HTTS(%p) - finalizing client(%p,%p,%d)\n", cli->htts, cli, cli->sck, (int)cli->sck->hnd);
|
HIO_DEBUG5 (cli->sck->hio, "HTTS(%p) - finalizing client(c=%p,sck=%p[%d],rsrc=%p)\n", cli->htts, cli, cli->sck, (int)cli->sck->hnd, cli->rsrc);
|
||||||
|
|
||||||
if (cli->rsrc)
|
if (cli->rsrc)
|
||||||
{
|
{
|
||||||
#if 0
|
HIO_SVC_HTTS_RSRC_UNREF (cli->rsrc);
|
||||||
hio_svc_htts_rsrc_kill (cli->rsrc);
|
|
||||||
cli->rsrc = HIO_NULL;
|
|
||||||
#else
|
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (cli->rsrc);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli->sbuf)
|
if (cli->sbuf)
|
||||||
@ -236,26 +231,27 @@ static void listener_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* xtn = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* xtn = hio_dev_sck_getxtn(sck);
|
||||||
|
hio_svc_htts_t* htts = xtn->htts;
|
||||||
|
|
||||||
switch (HIO_DEV_SCK_GET_PROGRESS(sck))
|
switch (HIO_DEV_SCK_GET_PROGRESS(sck))
|
||||||
{
|
{
|
||||||
case HIO_DEV_SCK_CONNECTING:
|
case HIO_DEV_SCK_CONNECTING:
|
||||||
/* only for connecting sockets */
|
/* only for connecting sockets */
|
||||||
HIO_DEBUG1 (hio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT %p[%d] TO REMOTE SERVER\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIO_DEV_SCK_CONNECTING_SSL:
|
case HIO_DEV_SCK_CONNECTING_SSL:
|
||||||
/* only for connecting sockets */
|
/* only for connecting sockets */
|
||||||
HIO_DEBUG1 (hio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT %p[%d] TO REMOTE SERVER\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIO_DEV_SCK_CONNECTED:
|
case HIO_DEV_SCK_CONNECTED:
|
||||||
/* only for connecting sockets */
|
/* only for connecting sockets */
|
||||||
HIO_DEBUG1 (hio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN %p(%d).......\n", (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - OUTGOING CLIENT CONNECTION GOT TORN DOWN %p[%d].......\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIO_DEV_SCK_LISTENING:
|
case HIO_DEV_SCK_LISTENING:
|
||||||
HIO_DEBUG2 (hio, "LISTNER SOCKET %p(%d) - SHUTTUING DOWN\n", sck, (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - LISTNER SOCKET %p[%d] - SHUTTUING DOWN\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HIO_DEV_SCK_ACCEPTING_SSL: /* special case. */
|
case HIO_DEV_SCK_ACCEPTING_SSL: /* special case. */
|
||||||
@ -264,17 +260,17 @@ static void listener_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
* the cli extension are is not initialized yet */
|
* the cli extension are is not initialized yet */
|
||||||
HIO_ASSERT (hio, sck != xtn->sck);
|
HIO_ASSERT (hio, sck != xtn->sck);
|
||||||
//HIO_ASSERT (hio, cli->sck == cli->htts->lsck); /* the field is a copy of the extension are of the listener socket. so it should point to the listner socket */
|
//HIO_ASSERT (hio, cli->sck == cli->htts->lsck); /* the field is a copy of the extension are of the listener socket. so it should point to the listner socket */
|
||||||
HIO_DEBUG2 (hio, "LISTENER UNABLE TO SSL-ACCEPT CLIENT %p(%d) ....%p\n", sck, (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - LISTENER UNABLE TO SSL-ACCEPT CLIENT %p[%d]\n", htts, sck, (int)sck->hnd);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case HIO_DEV_SCK_ACCEPTED:
|
case HIO_DEV_SCK_ACCEPTED:
|
||||||
/* only for sockets accepted by the listeners. will never come here because
|
/* only for sockets accepted by the listeners. will never come here because
|
||||||
* the disconnect call for such sockets have been changed in listener_on_connect() */
|
* the disconnect call for such sockets have been changed in listener_on_connect() */
|
||||||
HIO_DEBUG2 (hio, "ACCEPTED CLIENT SOCKET %p(%d) GOT DISCONNECTED.......\n", sck, (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - ACCEPTED CLIENT SOCKET %p[%d] GOT DISCONNECTED\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
HIO_DEBUG2 (hio, "SOCKET %p(%d) DISCONNECTED AFTER ALL.......\n", sck, (int)sck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - SOCKET %p[%d] DISCONNECTED AFTER ALL\n", htts, sck, (int)sck->hnd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,13 +280,13 @@ static void listener_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
HIO_ASSERT (hio, xtn->htrd == HIO_NULL);
|
HIO_ASSERT (hio, xtn->htrd == HIO_NULL);
|
||||||
HIO_ASSERT (hio, xtn->sbuf == HIO_NULL);
|
HIO_ASSERT (hio, xtn->sbuf == HIO_NULL);
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - listener socket disconnect %p\n", xtn->htts, sck);
|
HIO_DEBUG3 (hio, "HTTS(%p) - listener socket disconnect %p[%d]\n", xtn->htts, sck, (int)sck->hnd);
|
||||||
xtn->htts->l.sck[xtn->l_idx] = HIO_NULL; /* let the htts service forget about this listening socket */
|
xtn->htts->l.sck[xtn->l_idx] = HIO_NULL; /* let the htts service forget about this listening socket */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* client socket */
|
/* client socket */
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - client socket disconnect %p\n", xtn->htts, sck);
|
HIO_DEBUG3 (hio, "HTTS(%p) - client socket disconnect %p[%d]\n", xtn->htts, sck, (int)sck->hnd);
|
||||||
HIO_ASSERT (hio, xtn->sck == sck);
|
HIO_ASSERT (hio, xtn->sck == sck);
|
||||||
fini_client (xtn);
|
fini_client (xtn);
|
||||||
}
|
}
|
||||||
@ -299,7 +295,6 @@ static void listener_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
#define MAX_CLIENT_IDLE 10
|
#define MAX_CLIENT_IDLE 10
|
||||||
|
|
||||||
|
|
||||||
static void halt_idle_clients (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job)
|
static void halt_idle_clients (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job)
|
||||||
{
|
{
|
||||||
/* TODO: this idle client detector is far away from being accurate.
|
/* TODO: this idle client detector is far away from being accurate.
|
||||||
@ -396,6 +391,10 @@ hio_svc_htts_t* hio_svc_htts_start (hio_t* hio, hio_oow_t xtnsize, hio_dev_sck_b
|
|||||||
HIO_DEBUG3 (hio, "HTTS(%p) - [%zu] unsupported bind address type %d\n", htts, i, (int)hio_skad_get_family(&binds[i].localaddr));
|
HIO_DEBUG3 (hio, "HTTS(%p) - [%zu] unsupported bind address type %d\n", htts, i, (int)hio_skad_get_family(&binds[i].localaddr));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the callback names(prefixed with listener_on_) are somewhat misleading because
|
||||||
|
* they are triggered on the client sockets because the accepted client sockets
|
||||||
|
* inherit them */
|
||||||
info.m.options = HIO_DEV_SCK_MAKE_LENIENT;
|
info.m.options = HIO_DEV_SCK_MAKE_LENIENT;
|
||||||
info.m.on_write = listener_on_write;
|
info.m.on_write = listener_on_write;
|
||||||
info.m.on_read = listener_on_read;
|
info.m.on_read = listener_on_read;
|
||||||
@ -539,13 +538,23 @@ void hio_svc_htts_stop (hio_svc_htts_t* htts)
|
|||||||
hio_dev_sck_kill (cli->sck);
|
hio_dev_sck_kill (cli->sck);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
while (!HIO_SVC_HTTS_TASKL_IS_EMPTY(&htts->task))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
HIO_SVCL_UNLINK_SVC (htts);
|
HIO_SVCL_UNLINK_SVC (htts);
|
||||||
if (htts->server_name && htts->server_name != htts->server_name_buf) hio_freemem (hio, htts->server_name);
|
if (htts->server_name && htts->server_name != htts->server_name_buf) hio_freemem (hio, htts->server_name);
|
||||||
|
|
||||||
if (htts->idle_tmridx != HIO_TMRIDX_INVALID) hio_deltmrjob (hio, htts->idle_tmridx);
|
if (htts->idle_tmridx != HIO_TMRIDX_INVALID) hio_deltmrjob (hio, htts->idle_tmridx);
|
||||||
|
|
||||||
if (htts->l.sck) hio_freemem (hio, htts->l.sck);
|
if (htts->l.sck) hio_freemem (hio, htts->l.sck);
|
||||||
|
|
||||||
hio_freemem (hio, htts);
|
hio_freemem (hio, htts);
|
||||||
|
|
||||||
|
HIO_DEBUG1 (hio, "HTTS - STOPPED SERVICE %p\n", htts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* hio_svc_htts_getxtn (hio_svc_htts_t* htts)
|
void* hio_svc_htts_getxtn (hio_svc_htts_t* htts)
|
||||||
@ -636,22 +645,35 @@ hio_svc_htts_rsrc_t* hio_svc_htts_rsrc_make (hio_svc_htts_t* htts, hio_oow_t rsr
|
|||||||
hio_t* hio = htts->hio;
|
hio_t* hio = htts->hio;
|
||||||
hio_svc_htts_rsrc_t* rsrc;
|
hio_svc_htts_rsrc_t* rsrc;
|
||||||
|
|
||||||
|
HIO_DEBUG1 (hio, "HTTS(%p) - allocating resource\n", htts);
|
||||||
|
|
||||||
rsrc = hio_callocmem(hio, rsrc_size);
|
rsrc = hio_callocmem(hio, rsrc_size);
|
||||||
if (HIO_UNLIKELY(!rsrc)) return HIO_NULL;
|
if (HIO_UNLIKELY(!rsrc))
|
||||||
|
{
|
||||||
|
HIO_DEBUG1 (hio, "HTTS(%p) - failed to allocate resource\n", htts);
|
||||||
|
return HIO_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
rsrc->htts = htts;
|
rsrc->htts = htts;
|
||||||
rsrc->rsrc_size = rsrc_size;
|
rsrc->rsrc_size = rsrc_size;
|
||||||
rsrc->rsrc_refcnt = 0;
|
rsrc->rsrc_refcnt = 0;
|
||||||
rsrc->rsrc_on_kill = on_kill;
|
rsrc->rsrc_on_kill = on_kill;
|
||||||
|
|
||||||
|
HIO_DEBUG2 (hio, "HTTS(%p) - allocated resource %p\n", htts, rsrc);
|
||||||
return rsrc;
|
return rsrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hio_svc_htts_rsrc_kill (hio_svc_htts_rsrc_t* rsrc)
|
void hio_svc_htts_rsrc_kill (hio_svc_htts_rsrc_t* rsrc)
|
||||||
{
|
{
|
||||||
hio_t* hio = rsrc->htts->hio;
|
hio_svc_htts_t* htts = rsrc->htts;
|
||||||
|
hio_t* hio = htts->hio;
|
||||||
|
|
||||||
|
HIO_DEBUG2 (hio, "HTTS(%p) - destroying resource %p\n", htts, rsrc);
|
||||||
|
|
||||||
if (rsrc->rsrc_on_kill) rsrc->rsrc_on_kill (rsrc);
|
if (rsrc->rsrc_on_kill) rsrc->rsrc_on_kill (rsrc);
|
||||||
hio_freemem (hio, rsrc);
|
hio_freemem (hio, rsrc);
|
||||||
|
|
||||||
|
HIO_DEBUG2 (hio, "HTTS(%p) - destroyed resource %p\n", htts, rsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
602
lib/http-thr.c
602
lib/http-thr.c
File diff suppressed because it is too large
Load Diff
@ -141,7 +141,7 @@ static HIO_INLINE void txt_mark_over (txt_t* txt, int over_bits)
|
|||||||
HIO_ASSERT (txt->htts->hio, txt->client->rsrc == (hio_svc_htts_rsrc_t*)txt);
|
HIO_ASSERT (txt->htts->hio, txt->client->rsrc == (hio_svc_htts_rsrc_t*)txt);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", txt->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", txt->client->rsrc);*/
|
||||||
HIO_SVC_HTTS_RSRC_DETACH (txt->client->rsrc);
|
HIO_SVC_HTTS_RSRC_UNREF (txt->client->rsrc);
|
||||||
/* txt must not be access from here down as it could have been destroyed */
|
/* txt must not be access from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -153,8 +153,9 @@ static HIO_INLINE void txt_mark_over (txt_t* txt, int over_bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void txt_on_kill (txt_t* txt)
|
static void txt_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
||||||
{
|
{
|
||||||
|
txt_t* txt = (txt_t*)rsrc;
|
||||||
hio_t* hio = txt->htts->hio;
|
hio_t* hio = txt->htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - killing txt client(%p)\n", txt->htts, txt->client->sck);
|
HIO_DEBUG2 (hio, "HTTS(%p) - killing txt client(%p)\n", txt->htts, txt->client->sck);
|
||||||
@ -345,7 +346,7 @@ int hio_svc_htts_dotxt (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
csck->on_disconnect = txt_client_on_disconnect;
|
csck->on_disconnect = txt_client_on_disconnect;
|
||||||
|
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_ATTACH ((hio_svc_htts_rsrc_t*)txt, cli->rsrc);
|
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)txt, cli->rsrc);
|
||||||
|
|
||||||
if (req->flags & HIO_HTRE_ATTR_EXPECT100)
|
if (req->flags & HIO_HTRE_ATTR_EXPECT100)
|
||||||
{
|
{
|
||||||
|
@ -628,7 +628,8 @@ int hio_scan_http_qparam (hio_bch_t* qparam, int (*qparamcb) (hio_bcs_t* key, hi
|
|||||||
|
|
||||||
hio_oow_t hio_escape_html_bchars (const hio_bch_t* str, hio_oow_t sln, hio_bch_t* buf, hio_oow_t len)
|
hio_oow_t hio_escape_html_bchars (const hio_bch_t* str, hio_oow_t sln, hio_bch_t* buf, hio_oow_t len)
|
||||||
{
|
{
|
||||||
hio_bch_t* ptr, * end = str + sln;
|
hio_bch_t* ptr;
|
||||||
|
const hio_bch_t* end = str + sln;
|
||||||
hio_oow_t reqlen = 0;
|
hio_oow_t reqlen = 0;
|
||||||
|
|
||||||
for (ptr = (hio_bch_t*)str; ptr < end; ptr++)
|
for (ptr = (hio_bch_t*)str; ptr < end; ptr++)
|
||||||
|
@ -489,8 +489,9 @@ static int dev_sck_kill (hio_dev_t* dev, int force)
|
|||||||
{
|
{
|
||||||
hio_t* hio = dev->hio;
|
hio_t* hio = dev->hio;
|
||||||
hio_dev_sck_t* rdev = (hio_dev_sck_t*)dev;
|
hio_dev_sck_t* rdev = (hio_dev_sck_t*)dev;
|
||||||
|
int hnd = rdev->hnd;
|
||||||
|
|
||||||
HIO_DEBUG1 (hio, "SCK(%p) - being killed\n", rdev);
|
HIO_DEBUG2 (hio, "SCK(%p) - being killed [%d]\n", rdev, hnd);
|
||||||
#if 0
|
#if 0
|
||||||
if (IS_STREAM(rdev))
|
if (IS_STREAM(rdev))
|
||||||
{
|
{
|
||||||
@ -543,6 +544,8 @@ static int dev_sck_kill (hio_dev_t* dev, int force)
|
|||||||
close (rdev->side_chan);
|
close (rdev->side_chan);
|
||||||
rdev->side_chan = HIO_SYSHND_INVALID;
|
rdev->side_chan = HIO_SYSHND_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HIO_DEBUG2 (hio, "SCK(%p) - killed [%d]\n", rdev, (int)hnd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ int hio_sys_ctrlmux (hio_t* hio, hio_sys_mux_cmd_t cmd, hio_dev_t* dev, int dev_
|
|||||||
HIO_ASSERT (hio, hio == dev->hio);
|
HIO_ASSERT (hio, hio == dev->hio);
|
||||||
|
|
||||||
/* no operation over a broken(closed) handle to prevent multiplexer from failing.
|
/* no operation over a broken(closed) handle to prevent multiplexer from failing.
|
||||||
* close of the handle leads to auto-deletion from the epoll multiplexer.
|
* close() of the handle leads to auto-deletion from the epoll multiplexer.
|
||||||
* the closed handle must not be fed to the multiplexer */
|
* the closed handle must not be fed to the multiplexer */
|
||||||
if (dev->dev_mth->issyshndbroken && dev->dev_mth->issyshndbroken(dev)) return 0;
|
if (dev->dev_mth->issyshndbroken && dev->dev_mth->issyshndbroken(dev)) return 0;
|
||||||
hnd = dev->dev_mth->getsyshnd(dev);
|
hnd = dev->dev_mth->getsyshnd(dev);
|
||||||
|
Reference in New Issue
Block a user