renamed rsrc to task in the htts service
This commit is contained in:
parent
d9cadf0793
commit
eb1f8af86b
@ -81,27 +81,27 @@ typedef struct hio_svc_httc_t hio_svc_httc_t;
|
|||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct hio_svc_htts_rsrc_t hio_svc_htts_rsrc_t;
|
typedef struct hio_svc_htts_task_t hio_svc_htts_task_t;
|
||||||
|
|
||||||
typedef void (*hio_svc_htts_rsrc_on_kill_t) (
|
typedef void (*hio_svc_htts_task_on_kill_t) (
|
||||||
hio_svc_htts_rsrc_t* rsrc
|
hio_svc_htts_task_t* task
|
||||||
);
|
);
|
||||||
|
|
||||||
#define HIO_SVC_HTTS_RSRC_HEADER \
|
#define HIO_SVC_HTTS_TASK_HEADER \
|
||||||
hio_svc_htts_t* htts; \
|
hio_svc_htts_t* htts; \
|
||||||
hio_oow_t rsrc_size; \
|
hio_oow_t task_size; \
|
||||||
hio_oow_t rsrc_refcnt; \
|
hio_oow_t task_refcnt; \
|
||||||
hio_svc_htts_rsrc_t* task_prev; \
|
hio_svc_htts_task_t* task_prev; \
|
||||||
hio_svc_htts_rsrc_t* task_next; \
|
hio_svc_htts_task_t* task_next; \
|
||||||
hio_svc_htts_rsrc_on_kill_t rsrc_on_kill
|
hio_svc_htts_task_on_kill_t task_on_kill
|
||||||
|
|
||||||
struct hio_svc_htts_rsrc_t
|
struct hio_svc_htts_task_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define HIO_SVC_HTTS_RSRC_REF(rsrc, var) do { (var) = (rsrc); ++(rsrc)->rsrc_refcnt; } while(0)
|
#define HIO_SVC_HTTS_TASK_REF(task, var) do { (var) = (task); ++(task)->task_refcnt; } 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)
|
#define HIO_SVC_HTTS_TASK_UNREF(task_var) do { if (--(task_var)->task_refcnt == 0) { hio_svc_htts_task_t* __task_tmp = (task_var); (task_var) = HIO_NULL; hio_svc_htts_task_kill(__task_tmp); } else { (task_var) = HIO_NULL; } } while(0)
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
@ -431,14 +431,14 @@ HIO_EXPORT int hio_svc_htts_dotxt (
|
|||||||
int options
|
int options
|
||||||
);
|
);
|
||||||
|
|
||||||
HIO_EXPORT hio_svc_htts_rsrc_t* hio_svc_htts_rsrc_make (
|
HIO_EXPORT hio_svc_htts_task_t* hio_svc_htts_task_make (
|
||||||
hio_svc_htts_t* htts,
|
hio_svc_htts_t* htts,
|
||||||
hio_oow_t rsrc_size,
|
hio_oow_t task_size,
|
||||||
hio_svc_htts_rsrc_on_kill_t on_kill
|
hio_svc_htts_task_on_kill_t on_kill
|
||||||
);
|
);
|
||||||
|
|
||||||
HIO_EXPORT void hio_svc_htts_rsrc_kill (
|
HIO_EXPORT void hio_svc_htts_task_kill (
|
||||||
hio_svc_htts_rsrc_t* rsrc
|
hio_svc_htts_task_t* task
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ typedef enum cgi_res_mode_t cgi_res_mode_t;
|
|||||||
|
|
||||||
struct cgi_t
|
struct cgi_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
|
|
||||||
int options;
|
int options;
|
||||||
hio_oow_t num_pending_writes_to_client;
|
hio_oow_t num_pending_writes_to_client;
|
||||||
@ -231,10 +231,10 @@ static HIO_INLINE void cgi_mark_over (cgi_t* cgi, int over_bits)
|
|||||||
if (cgi->keep_alive && !cgi->client_eof_detected)
|
if (cgi->keep_alive && !cgi->client_eof_detected)
|
||||||
{
|
{
|
||||||
/* how to arrange to delete this cgi object and put the socket back to the normal waiting state??? */
|
/* how to arrange to delete this cgi object and put the socket back to the normal waiting state??? */
|
||||||
HIO_ASSERT (cgi->htts->hio, cgi->client->rsrc == (hio_svc_htts_rsrc_t*)cgi);
|
HIO_ASSERT (cgi->htts->hio, cgi->client->task == (hio_svc_htts_task_t*)cgi);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", cgi->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT TASK... state -> %p\n", cgi->client->task);*/
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (cgi->client->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (cgi->client->task);
|
||||||
/* 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,9 +246,9 @@ static HIO_INLINE void cgi_mark_over (cgi_t* cgi, int over_bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cgi_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
static void cgi_on_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
cgi_t* cgi = (cgi_t*)rsrc;
|
cgi_t* cgi = (cgi_t*)task;
|
||||||
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,8 +323,8 @@ static void peer_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
|
|||||||
cgi->peer = HIO_NULL; /* clear this peer from the state */
|
cgi->peer = HIO_NULL; /* clear this peer from the state */
|
||||||
|
|
||||||
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->task_refcnt);*/
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (peer_xtn->cgi);
|
HIO_SVC_HTTS_TASK_UNREF (peer_xtn->cgi);
|
||||||
|
|
||||||
if (cgi->peer_htrd)
|
if (cgi->peer_htrd)
|
||||||
{
|
{
|
||||||
@ -332,8 +332,8 @@ static void peer_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
|
|||||||
* it's safe to detach the extra information attached on the htrd object. */
|
* it's safe to detach the extra information attached on the htrd object. */
|
||||||
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->task_refcnt);*/
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (peer_xtn->cgi);
|
HIO_SVC_HTTS_TASK_UNREF (peer_xtn->cgi);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -588,7 +588,7 @@ static int cgi_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
cgi_t* cgi = (cgi_t*)cli->rsrc;
|
cgi_t* cgi = (cgi_t*)cli->task;
|
||||||
|
|
||||||
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
|
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ static int cgi_client_htrd_push_content (hio_htrd_t* htrd, hio_htre_t* req, cons
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
cgi_t* cgi = (cgi_t*)cli->rsrc;
|
cgi_t* cgi = (cgi_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (sck->hio, cli->sck == sck);
|
HIO_ASSERT (sck->hio, cli->sck == sck);
|
||||||
return cgi_write_to_peer(cgi, data, dlen);
|
return cgi_write_to_peer(cgi, data, dlen);
|
||||||
@ -671,7 +671,7 @@ oops:
|
|||||||
static void cgi_client_on_disconnect (hio_dev_sck_t* sck)
|
static void cgi_client_on_disconnect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
cgi_t* cgi = (cgi_t*)cli->rsrc;
|
cgi_t* cgi = (cgi_t*)cli->task;
|
||||||
cgi->client_disconnected = 1;
|
cgi->client_disconnected = 1;
|
||||||
cgi->client_org_on_disconnect (sck);
|
cgi->client_org_on_disconnect (sck);
|
||||||
}
|
}
|
||||||
@ -680,7 +680,7 @@ static int cgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
cgi_t* cgi = (cgi_t*)cli->rsrc;
|
cgi_t* cgi = (cgi_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
|
|
||||||
@ -734,7 +734,7 @@ static int cgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrc
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
cgi_t* cgi = (cgi_t*)cli->rsrc;
|
cgi_t* cgi = (cgi_t*)cli->task;
|
||||||
|
|
||||||
if (wrlen <= -1)
|
if (wrlen <= -1)
|
||||||
{
|
{
|
||||||
@ -954,7 +954,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
mi.on_fork = peer_on_fork;
|
mi.on_fork = peer_on_fork;
|
||||||
mi.fork_ctx = &fc;
|
mi.fork_ctx = &fc;
|
||||||
|
|
||||||
cgi = (cgi_t*)hio_svc_htts_rsrc_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill);
|
cgi = (cgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill);
|
||||||
if (HIO_UNLIKELY(!cgi)) goto oops;
|
if (HIO_UNLIKELY(!cgi)) goto oops;
|
||||||
|
|
||||||
cgi->options = options;
|
cgi->options = options;
|
||||||
@ -973,8 +973,8 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
csck->on_write = cgi_client_on_write;
|
csck->on_write = cgi_client_on_write;
|
||||||
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->task == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)cgi, cli->rsrc); /* cli->rsrc = cgi */
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)cgi, cli->task); /* cli->task = cgi */
|
||||||
|
|
||||||
if (access(mi.cmd, X_OK) == -1)
|
if (access(mi.cmd, X_OK) == -1)
|
||||||
{
|
{
|
||||||
@ -985,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_REF ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in pro = cgi */
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_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;
|
||||||
@ -993,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_REF ((hio_svc_htts_rsrc_t*)cgi, peer_xtn->cgi); /* peer->cgi in htrd = cgi */
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_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)
|
||||||
|
@ -24,7 +24,7 @@ typedef enum fcgi_res_mode_t fcgi_res_mode_t;
|
|||||||
|
|
||||||
struct fcgi_t
|
struct fcgi_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
|
|
||||||
hio_oow_t num_pending_writes_to_client;
|
hio_oow_t num_pending_writes_to_client;
|
||||||
hio_oow_t num_pending_writes_to_peer;
|
hio_oow_t num_pending_writes_to_peer;
|
||||||
@ -160,10 +160,10 @@ printf (">>>>>>>>>>>> disableing client read watching ...................\n");
|
|||||||
if (fcgi->keep_alive)
|
if (fcgi->keep_alive)
|
||||||
{
|
{
|
||||||
/* how to arrange to delete this fcgi object and put the socket back to the normal waiting state??? */
|
/* how to arrange to delete this fcgi object and put the socket back to the normal waiting state??? */
|
||||||
HIO_ASSERT (fcgi->htts->hio, fcgi->client->rsrc == (hio_svc_htts_rsrc_t*)fcgi);
|
HIO_ASSERT (fcgi->htts->hio, fcgi->client->task == (hio_svc_htts_task_t*)fcgi);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", fcgi->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT TASK... state -> %p\n", fcgi->client->task);*/
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (fcgi->client->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (fcgi->client->task);
|
||||||
/* 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
|
||||||
@ -221,7 +221,7 @@ static int fcgi_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
fcgi_t* fcgi = (fcgi_t*)cli->rsrc;
|
fcgi_t* fcgi = (fcgi_t*)cli->task;
|
||||||
|
|
||||||
/* indicate end of STDIN */
|
/* indicate end of STDIN */
|
||||||
if (hio_svc_fcgic_writestdin(fcgi->peer, HIO_NULL, 0) <= -1) return -1;
|
if (hio_svc_fcgic_writestdin(fcgi->peer, HIO_NULL, 0) <= -1) return -1;
|
||||||
@ -235,7 +235,7 @@ static int fcgi_client_htrd_push_content (hio_htrd_t* htrd, hio_htre_t* req, con
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
fcgi_t* fcgi = (fcgi_t*)cli->rsrc;
|
fcgi_t* fcgi = (fcgi_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (sck->hio, cli->sck == sck);
|
HIO_ASSERT (sck->hio, cli->sck == sck);
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ static hio_htrd_recbs_t fcgi_client_htrd_recbs =
|
|||||||
static void fcgi_client_on_disconnect (hio_dev_sck_t* sck)
|
static void fcgi_client_on_disconnect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
fcgi_t* fcgi = (fcgi_t*)cli->rsrc;
|
fcgi_t* fcgi = (fcgi_t*)cli->task;
|
||||||
fcgi->client_disconnected = 1;
|
fcgi->client_disconnected = 1;
|
||||||
printf ("client disconnected ............................\n");
|
printf ("client disconnected ............................\n");
|
||||||
fcgi->client_org_on_disconnect (sck);
|
fcgi->client_org_on_disconnect (sck);
|
||||||
@ -263,7 +263,7 @@ static int fcgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
fcgi_t* fcgi = (fcgi_t*)cli->rsrc;
|
fcgi_t* fcgi = (fcgi_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ static int fcgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wr
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
fcgi_t* fcgi = (fcgi_t*)cli->rsrc;
|
fcgi_t* fcgi = (fcgi_t*)cli->task;
|
||||||
|
|
||||||
if (wrlen <= -1)
|
if (wrlen <= -1)
|
||||||
{
|
{
|
||||||
@ -371,9 +371,9 @@ printf ("GOT FCGI DATA.............[%.*s]\n", (int)len, buf);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fcgi_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
static void fcgi_on_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
fcgi_t* fcgi = (fcgi_t*)rsrc;
|
fcgi_t* fcgi = (fcgi_t*)task;
|
||||||
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);
|
||||||
@ -501,7 +501,7 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
fcgi = (fcgi_t*)hio_svc_htts_rsrc_make(htts, HIO_SIZEOF(*fcgi), fcgi_on_kill);
|
fcgi = (fcgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*fcgi), fcgi_on_kill);
|
||||||
if (HIO_UNLIKELY(!fcgi)) goto oops;
|
if (HIO_UNLIKELY(!fcgi)) goto oops;
|
||||||
|
|
||||||
fcgi->client = cli;
|
fcgi->client = cli;
|
||||||
@ -519,8 +519,8 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
csck->on_write = fcgi_client_on_write;
|
csck->on_write = fcgi_client_on_write;
|
||||||
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->task == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)fcgi, cli->rsrc); /* cli->rsrc = fcgi */
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)fcgi, cli->task); /* cli->task = 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);
|
||||||
|
@ -51,7 +51,7 @@ typedef enum file_res_mode_t file_res_mode_t;
|
|||||||
|
|
||||||
struct file_t
|
struct file_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
|
|
||||||
int options;
|
int options;
|
||||||
hio_svc_htts_file_cbs_t* cbs;
|
hio_svc_htts_file_cbs_t* cbs;
|
||||||
@ -226,16 +226,16 @@ static void file_mark_over (file_t* file, int over_bits)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 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->task == (hio_svc_htts_task_t*)file);
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (file->client->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (file->client->task);
|
||||||
/* the file resource must not be accessed from here down as it could have been destroyed */
|
/* the file task must not be accessed from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HIO_DEBUG4 (file->htts->hio, "HTTS(%p) - file(c=%d,p=%d) halting client for %hs\n", file->htts, (int)file->client->sck->hnd, file->peer, (file->client_eof_detected? "EOF detected": "no keep-alive"));
|
HIO_DEBUG4 (file->htts->hio, "HTTS(%p) - file(c=%d,p=%d) halting client for %hs\n", file->htts, (int)file->client->sck->hnd, file->peer, (file->client_eof_detected? "EOF detected": "no keep-alive"));
|
||||||
hio_dev_sck_shutdown (file->client->sck, HIO_DEV_SCK_SHUTDOWN_WRITE);
|
hio_dev_sck_shutdown (file->client->sck, HIO_DEV_SCK_SHUTDOWN_WRITE);
|
||||||
hio_dev_sck_halt (file->client->sck);
|
hio_dev_sck_halt (file->client->sck);
|
||||||
/* the file resource will be detached from file->client->rsrc by the upstream disconnect handler in http_svr.c */
|
/* the file task will be detached from file->client->task by the upstream disconnect handler in http_svr.c */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,9 +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 (hio_svc_htts_rsrc_t* rsrc)
|
static void file_on_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
file_t* file = (file_t*)rsrc;
|
file_t* file = (file_t*)task;
|
||||||
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);
|
||||||
@ -322,7 +322,7 @@ static void file_client_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
file_t* file = (file_t*)cli->rsrc;
|
file_t* file = (file_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
HIO_ASSERT (hio, sck == file->client->sck);
|
HIO_ASSERT (hio, sck == file->client->sck);
|
||||||
@ -333,15 +333,15 @@ static void file_client_on_disconnect (hio_dev_sck_t* sck)
|
|||||||
file->client_org_on_disconnect (sck);
|
file->client_org_on_disconnect (sck);
|
||||||
|
|
||||||
/* the original disconnect handler (listener_on_disconnect in http-svr.c)
|
/* the original disconnect handler (listener_on_disconnect in http-svr.c)
|
||||||
* frees the file resource attached to the client. so it must not be accessed */
|
* frees the file task attached to the client. so it must not be accessed */
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->task == HIO_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int file_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
|
static int file_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
|
||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
file_t* file = (file_t*)cli->rsrc;
|
file_t* file = (file_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
HIO_ASSERT (hio, sck == file->client->sck);
|
HIO_ASSERT (hio, sck == file->client->sck);
|
||||||
@ -400,7 +400,7 @@ static int file_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wr
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
file_t* file = (file_t*)cli->rsrc;
|
file_t* file = (file_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
HIO_ASSERT (hio, sck == file->client->sck);
|
HIO_ASSERT (hio, sck == file->client->sck);
|
||||||
@ -452,7 +452,7 @@ static int file_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
file_t* file = (file_t*)cli->rsrc;
|
file_t* file = (file_t*)cli->task;
|
||||||
|
|
||||||
/* indicate EOF to the client peer */
|
/* indicate EOF to the client peer */
|
||||||
if (file_write_to_peer(file, HIO_NULL, 0) <= -1) return -1;
|
if (file_write_to_peer(file, HIO_NULL, 0) <= -1) return -1;
|
||||||
@ -471,7 +471,7 @@ static int file_client_htrd_push_content (hio_htrd_t* htrd, hio_htre_t* req, con
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
file_t* file = (file_t*)cli->rsrc;
|
file_t* file = (file_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (sck->hio, cli->sck == sck);
|
HIO_ASSERT (sck->hio, cli->sck == sck);
|
||||||
return file_write_to_peer(file, data, dlen);
|
return file_write_to_peer(file, data, dlen);
|
||||||
@ -783,7 +783,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
actual_file = hio_svc_htts_dupmergepaths(htts, docroot, filepath);
|
actual_file = hio_svc_htts_dupmergepaths(htts, docroot, filepath);
|
||||||
if (HIO_UNLIKELY(!actual_file)) goto oops;
|
if (HIO_UNLIKELY(!actual_file)) goto oops;
|
||||||
|
|
||||||
file = (file_t*)hio_svc_htts_rsrc_make(htts, HIO_SIZEOF(*file), file_on_kill);
|
file = (file_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*file), file_on_kill);
|
||||||
if (HIO_UNLIKELY(!file)) goto oops;
|
if (HIO_UNLIKELY(!file)) goto oops;
|
||||||
|
|
||||||
file->options = options;
|
file->options = options;
|
||||||
@ -796,7 +796,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
file->req_method = hio_htre_getqmethodtype(req);
|
file->req_method = hio_htre_getqmethodtype(req);
|
||||||
file->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &file->req_content_length);
|
file->req_content_length_unlimited = hio_htre_getreqcontentlen(req, &file->req_content_length);
|
||||||
file->req_qpath = req_qpath;
|
file->req_qpath = req_qpath;
|
||||||
req_qpath = HIO_NULL; /* delegated to the file resource */
|
req_qpath = HIO_NULL; /* delegated to the file task */
|
||||||
file->req_qpath_ending_with_slash = (hio_htre_getqpathlen(req) > 0 && hio_htre_getqpath(req)[hio_htre_getqpathlen(req) - 1] == '/');
|
file->req_qpath_ending_with_slash = (hio_htre_getqpathlen(req) > 0 && hio_htre_getqpath(req)[hio_htre_getqpathlen(req) - 1] == '/');
|
||||||
file->req_qpath_is_root = (hio_htre_getqpathlen(req) == 1 && hio_htre_getqpath(req)[0] == '/');
|
file->req_qpath_is_root = (hio_htre_getqpathlen(req) == 1 && hio_htre_getqpath(req)[0] == '/');
|
||||||
|
|
||||||
@ -810,8 +810,8 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
|
|||||||
file->peer_tmridx = HIO_TMRIDX_INVALID;
|
file->peer_tmridx = HIO_TMRIDX_INVALID;
|
||||||
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->task == HIO_NULL); /* you must not call this function while cli->task is not HIO_NULL */
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)file, cli->rsrc); /* cli->rsrc = file with ref-count up */
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)file, cli->task); /* cli->task = file with ref-count up */
|
||||||
|
|
||||||
|
|
||||||
#if !defined(FILE_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
#if !defined(FILE_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||||
|
@ -47,7 +47,7 @@ struct hio_svc_htts_cli_t
|
|||||||
hio_htrd_t* htrd;
|
hio_htrd_t* htrd;
|
||||||
hio_becs_t* sbuf; /* temporary buffer for status line formatting */
|
hio_becs_t* sbuf; /* temporary buffer for status line formatting */
|
||||||
|
|
||||||
hio_svc_htts_rsrc_t* rsrc;
|
hio_svc_htts_task_t* task;
|
||||||
hio_ntime_t last_active;
|
hio_ntime_t last_active;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ struct hio_svc_htts_t
|
|||||||
hio_svc_fcgic_t* fcgic;
|
hio_svc_fcgic_t* fcgic;
|
||||||
|
|
||||||
hio_svc_htts_cli_t cli; /* list head for client list */
|
hio_svc_htts_cli_t cli; /* list head for client list */
|
||||||
hio_svc_htts_rsrc_t task; /* list head for task list */
|
hio_svc_htts_task_t task; /* list head for task list */
|
||||||
hio_tmridx_t idle_tmridx;
|
hio_tmridx_t idle_tmridx;
|
||||||
|
|
||||||
hio_bch_t* server_name;
|
hio_bch_t* server_name;
|
||||||
|
@ -58,7 +58,7 @@ static int init_client (hio_svc_htts_cli_t* cli, hio_dev_sck_t* sck)
|
|||||||
cli->l_idx = INVALID_LIDX; /* not a listening socket anymore */
|
cli->l_idx = INVALID_LIDX; /* not a listening socket anymore */
|
||||||
cli->htrd = HIO_NULL;
|
cli->htrd = HIO_NULL;
|
||||||
cli->sbuf = HIO_NULL;
|
cli->sbuf = HIO_NULL;
|
||||||
cli->rsrc = HIO_NULL;
|
cli->task = HIO_NULL;
|
||||||
/* keep this linked regardless of success or failure because the disconnect() callback
|
/* keep this linked regardless of success or failure because the disconnect() callback
|
||||||
* will call fini_client(). the error handler code after 'oops:' doesn't get this unlinked */
|
* will call fini_client(). the error handler code after 'oops:' doesn't get this unlinked */
|
||||||
HIO_SVC_HTTS_CLIL_APPEND_CLI (&cli->htts->cli, cli);
|
HIO_SVC_HTTS_CLIL_APPEND_CLI (&cli->htts->cli, cli);
|
||||||
@ -100,11 +100,11 @@ oops:
|
|||||||
|
|
||||||
static void fini_client (hio_svc_htts_cli_t* cli)
|
static void fini_client (hio_svc_htts_cli_t* cli)
|
||||||
{
|
{
|
||||||
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);
|
HIO_DEBUG5 (cli->sck->hio, "HTTS(%p) - finalizing client(c=%p,sck=%p[%d],task=%p)\n", cli->htts, cli, cli->sck, (int)cli->sck->hnd, cli->task);
|
||||||
|
|
||||||
if (cli->rsrc)
|
if (cli->task)
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (cli->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (cli->task);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cli->sbuf)
|
if (cli->sbuf)
|
||||||
@ -143,10 +143,10 @@ static int listener_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t le
|
|||||||
|
|
||||||
HIO_ASSERT (hio, cli->l_idx == INVALID_LIDX);
|
HIO_ASSERT (hio, cli->l_idx == INVALID_LIDX);
|
||||||
|
|
||||||
/* if a resource has been set(cli->rsrc not NULL), the resource must take over
|
/* if a task has been set(cli->task not NULL) on the client, the task must take over
|
||||||
* this handler. this handler is never called unless the the overriding handler
|
* this handler. this handler is never called unless the the overriding handler
|
||||||
* call this. */
|
* call this. */
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->task == HIO_NULL);
|
||||||
|
|
||||||
if (len <= -1)
|
if (len <= -1)
|
||||||
{
|
{
|
||||||
@ -169,7 +169,7 @@ static int listener_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t le
|
|||||||
|
|
||||||
if (rem > 0)
|
if (rem > 0)
|
||||||
{
|
{
|
||||||
if (cli->rsrc)
|
if (cli->task)
|
||||||
{
|
{
|
||||||
/* TODO store this to client buffer. once the current resource is completed, arrange to call on_read() with it */
|
/* TODO store this to client buffer. once the current resource is completed, arrange to call on_read() with it */
|
||||||
}
|
}
|
||||||
@ -193,10 +193,10 @@ static int listener_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx
|
|||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
HIO_ASSERT (sck->hio, cli->l_idx == INVALID_LIDX);
|
HIO_ASSERT (sck->hio, cli->l_idx == INVALID_LIDX);
|
||||||
|
|
||||||
/* if a resource has been set(cli->rsrc not NULL), the resource must take over
|
/* if a resource has been set(cli->task not NULL), the resource must take over
|
||||||
* this handler. this handler is never called unless the the overriding handler
|
* this handler. this handler is never called unless the the overriding handler
|
||||||
* call this. */
|
* call this. */
|
||||||
HIO_ASSERT (sck->hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (sck->hio, cli->task == HIO_NULL);
|
||||||
|
|
||||||
/* anyways, nothing to do upon write completion */
|
/* anyways, nothing to do upon write completion */
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ static void halt_idle_clients (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t*
|
|||||||
|
|
||||||
for (cli = HIO_SVC_HTTS_CLIL_FIRST_CLI(&htts->cli); !HIO_SVC_HTTS_CLIL_IS_NIL_CLI(&htts->cli, cli); cli = cli->cli_next)
|
for (cli = HIO_SVC_HTTS_CLIL_FIRST_CLI(&htts->cli); !HIO_SVC_HTTS_CLIL_IS_NIL_CLI(&htts->cli, cli); cli = cli->cli_next)
|
||||||
{
|
{
|
||||||
if (!cli->rsrc)
|
if (!cli->task)
|
||||||
{
|
{
|
||||||
hio_ntime_t t;
|
hio_ntime_t t;
|
||||||
HIO_SUB_NTIME(&t, now, &cli->last_active);
|
HIO_SUB_NTIME(&t, now, &cli->last_active);
|
||||||
@ -541,8 +541,8 @@ void hio_svc_htts_stop (hio_svc_htts_t* htts)
|
|||||||
|
|
||||||
while (!HIO_SVC_HTTS_TASKL_IS_EMPTY(&htts->task))
|
while (!HIO_SVC_HTTS_TASKL_IS_EMPTY(&htts->task))
|
||||||
{
|
{
|
||||||
hio_svc_htts_rsrc_t* task = HIO_SVC_HTTS_TASKL_FIRST_TASK(&htts->task);
|
hio_svc_htts_task_t* task = HIO_SVC_HTTS_TASKL_FIRST_TASK(&htts->task);
|
||||||
hio_svc_htts_rsrc_kill (task);
|
hio_svc_htts_task_kill (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
HIO_SVCL_UNLINK_SVC (htts);
|
HIO_SVCL_UNLINK_SVC (htts);
|
||||||
@ -627,53 +627,53 @@ int hio_svc_htts_getsockaddr (hio_svc_htts_t* htts, hio_oow_t idx, hio_skad_t* s
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
/* rsrc_size must be the total size to allocate including the header.
|
/* task_size must be the total size to allocate including the header.
|
||||||
*
|
*
|
||||||
* For instance, if you define a resource like below,
|
* For instance, if you define a task like below,
|
||||||
*
|
*
|
||||||
* struct my_rsrc_t
|
* struct my_task_t
|
||||||
* {
|
* {
|
||||||
* HIO_SVC_HTTS_RSRC_HEADER;
|
* HIO_SVC_HTTS_TASK_HEADER;
|
||||||
* int a;
|
* int a;
|
||||||
* int b;
|
* int b;
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* you can pass sizeof(my_rsrc_t) to hio_svc_htts_rsrc_make()
|
* you can pass sizeof(my_task_t) to hio_svc_htts_task_make()
|
||||||
*/
|
*/
|
||||||
hio_svc_htts_rsrc_t* hio_svc_htts_rsrc_make (hio_svc_htts_t* htts, hio_oow_t rsrc_size, hio_svc_htts_rsrc_on_kill_t on_kill)
|
hio_svc_htts_task_t* hio_svc_htts_task_make (hio_svc_htts_t* htts, hio_oow_t task_size, hio_svc_htts_task_on_kill_t on_kill)
|
||||||
{
|
{
|
||||||
hio_t* hio = htts->hio;
|
hio_t* hio = htts->hio;
|
||||||
hio_svc_htts_rsrc_t* rsrc;
|
hio_svc_htts_task_t* task;
|
||||||
|
|
||||||
HIO_DEBUG1 (hio, "HTTS(%p) - allocating resource\n", htts);
|
HIO_DEBUG1 (hio, "HTTS(%p) - allocating task\n", htts);
|
||||||
|
|
||||||
rsrc = hio_callocmem(hio, rsrc_size);
|
task = hio_callocmem(hio, task_size);
|
||||||
if (HIO_UNLIKELY(!rsrc))
|
if (HIO_UNLIKELY(!task))
|
||||||
{
|
{
|
||||||
HIO_DEBUG1 (hio, "HTTS(%p) - failed to allocate resource\n", htts);
|
HIO_DEBUG1 (hio, "HTTS(%p) - failed to allocate task\n", htts);
|
||||||
return HIO_NULL;
|
return HIO_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
rsrc->htts = htts;
|
task->htts = htts;
|
||||||
rsrc->rsrc_size = rsrc_size;
|
task->task_size = task_size;
|
||||||
rsrc->rsrc_refcnt = 0;
|
task->task_refcnt = 0;
|
||||||
rsrc->rsrc_on_kill = on_kill;
|
task->task_on_kill = on_kill;
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - allocated resource %p\n", htts, rsrc);
|
HIO_DEBUG2 (hio, "HTTS(%p) - allocated task %p\n", htts, task);
|
||||||
return rsrc;
|
return task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hio_svc_htts_rsrc_kill (hio_svc_htts_rsrc_t* rsrc)
|
void hio_svc_htts_task_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
hio_svc_htts_t* htts = rsrc->htts;
|
hio_svc_htts_t* htts = task->htts;
|
||||||
hio_t* hio = htts->hio;
|
hio_t* hio = htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - destroying resource %p\n", htts, rsrc);
|
HIO_DEBUG2 (hio, "HTTS(%p) - destroying task %p\n", htts, task);
|
||||||
|
|
||||||
if (rsrc->rsrc_on_kill) rsrc->rsrc_on_kill (rsrc);
|
if (task->task_on_kill) task->task_on_kill (task);
|
||||||
hio_freemem (hio, rsrc);
|
hio_freemem (hio, task);
|
||||||
|
|
||||||
HIO_DEBUG2 (hio, "HTTS(%p) - destroyed resource %p\n", htts, rsrc);
|
HIO_DEBUG2 (hio, "HTTS(%p) - destroyed task %p\n", htts, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
@ -59,7 +59,7 @@ typedef struct thr_func_start_t thr_func_start_t;
|
|||||||
|
|
||||||
struct thr_task_t
|
struct thr_task_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
|
|
||||||
int options;
|
int options;
|
||||||
hio_oow_t num_pending_writes_to_client;
|
hio_oow_t num_pending_writes_to_client;
|
||||||
@ -244,8 +244,8 @@ static HIO_INLINE void thr_task_mark_over (thr_task_t* thr_task, int over_bits)
|
|||||||
if (thr_task->keep_alive && !thr_task->client_eof_detected)
|
if (thr_task->keep_alive && !thr_task->client_eof_detected)
|
||||||
{
|
{
|
||||||
/* how to arrange to delete this thr_task object and put the socket back to the normal waiting state??? */
|
/* how to arrange to delete this thr_task object and put the socket back to the normal waiting state??? */
|
||||||
HIO_ASSERT (thr_task->htts->hio, thr_task->client->rsrc == (hio_svc_htts_rsrc_t*)thr_task);
|
HIO_ASSERT (thr_task->htts->hio, thr_task->client->task == (hio_svc_htts_task_t*)thr_task);
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (thr_task->client->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (thr_task->client->task);
|
||||||
/* IMPORTANT: thr_task must not be accessed from here down as it could have been destroyed */
|
/* IMPORTANT: thr_task must not be accessed from here down as it could have been destroyed */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -258,9 +258,9 @@ static HIO_INLINE void thr_task_mark_over (thr_task_t* thr_task, int over_bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thr_task_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
static void thr_task_on_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
thr_task_t* thr_task = (thr_task_t*)rsrc;
|
thr_task_t* thr_task = (thr_task_t*)task;
|
||||||
hio_t* hio = thr_task->htts->hio;
|
hio_t* hio = thr_task->htts->hio;
|
||||||
|
|
||||||
HIO_DEBUG5 (hio, "HTTS(%p) - thr(t=%p,c=%p[%d],p=%p) - killing the task\n", thr_task->htts, thr_task, thr_task->client, (thr_task->csck? thr_task->csck->hnd: -1), thr_task->peer);
|
HIO_DEBUG5 (hio, "HTTS(%p) - thr(t=%p,c=%p[%d],p=%p) - killing the task\n", thr_task->htts, thr_task, thr_task->client, (thr_task->csck? thr_task->csck->hnd: -1), thr_task->peer);
|
||||||
@ -271,7 +271,7 @@ static void thr_task_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
|||||||
if (thr_peer->task)
|
if (thr_peer->task)
|
||||||
{
|
{
|
||||||
/* thr_peer->task may not be NULL if the resource is killed regardless of the reference count.
|
/* thr_peer->task may not be NULL if the resource is killed regardless of the reference count.
|
||||||
* anyway, don't use HIO_SVC_HTTS_RSRC_UNREF (thr_peer->task) because the resource itself
|
* anyway, don't use HIO_SVC_HTTS_TASK_UNREF (thr_peer->task) because the resource itself
|
||||||
* is already being killed. */
|
* is already being killed. */
|
||||||
thr_peer->task = HIO_NULL;
|
thr_peer->task = HIO_NULL;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ static void thr_task_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
|||||||
if (thr_task->peer_htrd)
|
if (thr_task->peer_htrd)
|
||||||
{
|
{
|
||||||
thr_peer_xtn_t* thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
thr_peer_xtn_t* thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
||||||
if (thr_peer->task) thr_peer->task = HIO_NULL; // no HIO_SVC_HTTS_RSRC_UNREF() for the same reason above
|
if (thr_peer->task) thr_peer->task = HIO_NULL; // no HIO_SVC_HTTS_TASK_UNREF() for the same reason above
|
||||||
|
|
||||||
hio_htrd_close (thr_task->peer_htrd);
|
hio_htrd_close (thr_task->peer_htrd);
|
||||||
thr_task->peer_htrd = HIO_NULL;
|
thr_task->peer_htrd = HIO_NULL;
|
||||||
@ -330,7 +330,7 @@ static void thr_peer_on_close (hio_dev_thr_t* thr, hio_dev_thr_sid_t sid)
|
|||||||
thr_task->peer = HIO_NULL; /* clear this peer from the state */
|
thr_task->peer = HIO_NULL; /* clear this peer from the state */
|
||||||
|
|
||||||
HIO_ASSERT (hio, thr_peer->task != HIO_NULL);
|
HIO_ASSERT (hio, thr_peer->task != HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (thr_peer->task);
|
HIO_SVC_HTTS_TASK_UNREF (thr_peer->task);
|
||||||
|
|
||||||
if (thr_task->peer_htrd)
|
if (thr_task->peer_htrd)
|
||||||
{
|
{
|
||||||
@ -338,7 +338,7 @@ static void thr_peer_on_close (hio_dev_thr_t* thr, hio_dev_thr_sid_t sid)
|
|||||||
* it's safe to detach the extra information attached on the htrd object. */
|
* it's safe to detach the extra information attached on the htrd object. */
|
||||||
thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
||||||
HIO_ASSERT (hio, thr_peer->task != HIO_NULL);
|
HIO_ASSERT (hio, thr_peer->task != HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (thr_peer->task);
|
HIO_SVC_HTTS_TASK_UNREF (thr_peer->task);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -593,7 +593,7 @@ static int thr_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
thr_task_t* thr_task = (thr_task_t*)cli->rsrc;
|
thr_task_t* thr_task = (thr_task_t*)cli->task;
|
||||||
|
|
||||||
/* indicate EOF to the client peer */
|
/* indicate EOF to the client peer */
|
||||||
if (thr_task_write_to_peer(thr_task, HIO_NULL, 0) <= -1) return -1;
|
if (thr_task_write_to_peer(thr_task, HIO_NULL, 0) <= -1) return -1;
|
||||||
@ -607,7 +607,7 @@ static int thr_client_htrd_push_content (hio_htrd_t* htrd, hio_htre_t* req, cons
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
thr_task_t* thr_task = (thr_task_t*)cli->rsrc;
|
thr_task_t* thr_task = (thr_task_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (sck->hio, cli->sck == sck);
|
HIO_ASSERT (sck->hio, cli->sck == sck);
|
||||||
return thr_task_write_to_peer(thr_task, data, dlen);
|
return thr_task_write_to_peer(thr_task, data, dlen);
|
||||||
@ -674,7 +674,7 @@ oops:
|
|||||||
static void thr_client_on_disconnect (hio_dev_sck_t* sck)
|
static void thr_client_on_disconnect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
thr_task_t* thr_task = (thr_task_t*)cli->rsrc;
|
thr_task_t* thr_task = (thr_task_t*)cli->task;
|
||||||
hio_svc_htts_t* htts = thr_task->htts;
|
hio_svc_htts_t* htts = thr_task->htts;
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
|
|
||||||
@ -699,7 +699,7 @@ static int thr_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
thr_task_t* thr_task = (thr_task_t*)cli->rsrc;
|
thr_task_t* thr_task = (thr_task_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ static int thr_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrc
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
thr_task_t* thr_task = (thr_task_t*)cli->rsrc;
|
thr_task_t* thr_task = (thr_task_t*)cli->task;
|
||||||
|
|
||||||
if (wrlen <= -1)
|
if (wrlen <= -1)
|
||||||
{
|
{
|
||||||
@ -911,7 +911,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
mi.on_write = thr_peer_on_write;
|
mi.on_write = thr_peer_on_write;
|
||||||
mi.on_close = thr_peer_on_close;
|
mi.on_close = thr_peer_on_close;
|
||||||
|
|
||||||
thr_task = (thr_task_t*)hio_svc_htts_rsrc_make(htts, HIO_SIZEOF(*thr_task), thr_task_on_kill);
|
thr_task = (thr_task_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*thr_task), thr_task_on_kill);
|
||||||
if (HIO_UNLIKELY(!thr_task)) goto oops;
|
if (HIO_UNLIKELY(!thr_task)) goto oops;
|
||||||
|
|
||||||
thr_task->options = options;
|
thr_task->options = options;
|
||||||
@ -930,14 +930,14 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
csck->on_write = thr_client_on_write;
|
csck->on_write = thr_client_on_write;
|
||||||
csck->on_disconnect = thr_client_on_disconnect;
|
csck->on_disconnect = thr_client_on_disconnect;
|
||||||
|
|
||||||
/* attach the thr task to the client socket via the rsrc field in the extended space of the socket */
|
/* attach the thr task to the client socket via the task field in the extended space of the socket */
|
||||||
HIO_ASSERT (hio, cli->rsrc == HIO_NULL);
|
HIO_ASSERT (hio, cli->task == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)thr_task, cli->rsrc);
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)thr_task, cli->task);
|
||||||
|
|
||||||
thr_task->peer = hio_dev_thr_make(hio, HIO_SIZEOF(*thr_peer), &mi);
|
thr_task->peer = hio_dev_thr_make(hio, HIO_SIZEOF(*thr_peer), &mi);
|
||||||
if (HIO_UNLIKELY(!thr_task->peer))
|
if (HIO_UNLIKELY(!thr_task->peer))
|
||||||
{
|
{
|
||||||
/* no need to detach the attached rsrc here because that is handled
|
/* no need to detach the attached task here because that is handled
|
||||||
* in the kill/disconnect callbacks of relevant devices */
|
* in the kill/disconnect callbacks of relevant devices */
|
||||||
HIO_DEBUG3 (hio, "HTTS(%p) - failed to create thread for %p(%d)\n", htts, csck, (int)csck->hnd);
|
HIO_DEBUG3 (hio, "HTTS(%p) - failed to create thread for %p(%d)\n", htts, csck, (int)csck->hnd);
|
||||||
goto oops;
|
goto oops;
|
||||||
@ -947,7 +947,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
|
|
||||||
/* attach the thr task to the peer thread device */
|
/* attach the thr task to the peer thread device */
|
||||||
thr_peer = hio_dev_thr_getxtn(thr_task->peer);
|
thr_peer = hio_dev_thr_getxtn(thr_task->peer);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)thr_task, thr_peer->task);
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)thr_task, thr_peer->task);
|
||||||
|
|
||||||
thr_task->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*thr_peer));
|
thr_task->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*thr_peer));
|
||||||
if (HIO_UNLIKELY(!thr_task->peer_htrd)) goto oops;
|
if (HIO_UNLIKELY(!thr_task->peer_htrd)) goto oops;
|
||||||
@ -956,7 +956,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
|
|
||||||
/* attach the thr task to the htrd parser set on the peer thread device */
|
/* attach the thr task to the htrd parser set on the peer thread device */
|
||||||
thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
thr_peer = hio_htrd_getxtn(thr_task->peer_htrd);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)thr_task, thr_peer->task);
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)thr_task, thr_peer->task);
|
||||||
|
|
||||||
#if !defined(THR_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
#if !defined(THR_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH)
|
||||||
if (thr_task->req_content_length_unlimited)
|
if (thr_task->req_content_length_unlimited)
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
struct txt_t
|
struct txt_t
|
||||||
{
|
{
|
||||||
HIO_SVC_HTTS_RSRC_HEADER;
|
HIO_SVC_HTTS_TASK_HEADER;
|
||||||
|
|
||||||
int options;
|
int options;
|
||||||
hio_oow_t num_pending_writes_to_client;
|
hio_oow_t num_pending_writes_to_client;
|
||||||
@ -138,10 +138,10 @@ static HIO_INLINE void txt_mark_over (txt_t* txt, int over_bits)
|
|||||||
if (txt->keep_alive && !txt->client_eof_detected)
|
if (txt->keep_alive && !txt->client_eof_detected)
|
||||||
{
|
{
|
||||||
/* how to arrange to delete this txt object and put the socket back to the normal waiting state??? */
|
/* how to arrange to delete this txt object and put the socket back to the normal waiting state??? */
|
||||||
HIO_ASSERT (txt->htts->hio, txt->client->rsrc == (hio_svc_htts_rsrc_t*)txt);
|
HIO_ASSERT (txt->htts->hio, txt->client->task == (hio_svc_htts_task_t*)txt);
|
||||||
|
|
||||||
/*printf ("DETACHING FROM THE MAIN CLIENT RSRC... state -> %p\n", txt->client->rsrc);*/
|
/*printf ("DETACHING FROM THE MAIN CLIENT TASK... state -> %p\n", txt->client->task);*/
|
||||||
HIO_SVC_HTTS_RSRC_UNREF (txt->client->rsrc);
|
HIO_SVC_HTTS_TASK_UNREF (txt->client->task);
|
||||||
/* 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,9 +153,9 @@ static HIO_INLINE void txt_mark_over (txt_t* txt, int over_bits)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void txt_on_kill (hio_svc_htts_rsrc_t* rsrc)
|
static void txt_on_kill (hio_svc_htts_task_t* task)
|
||||||
{
|
{
|
||||||
txt_t* txt = (txt_t*)rsrc;
|
txt_t* txt = (txt_t*)task;
|
||||||
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);
|
||||||
@ -203,7 +203,7 @@ static int txt_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
|
|||||||
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
|
||||||
hio_dev_sck_t* sck = htrdxtn->sck;
|
hio_dev_sck_t* sck = htrdxtn->sck;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
txt_t* txt = (txt_t*)cli->rsrc;
|
txt_t* txt = (txt_t*)cli->task;
|
||||||
|
|
||||||
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
|
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ static hio_htrd_recbs_t txt_client_htrd_recbs =
|
|||||||
static void txt_client_on_disconnect (hio_dev_sck_t* sck)
|
static void txt_client_on_disconnect (hio_dev_sck_t* sck)
|
||||||
{
|
{
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
txt_t* txt = (txt_t*)cli->rsrc;
|
txt_t* txt = (txt_t*)cli->task;
|
||||||
txt->client_disconnected = 1;
|
txt->client_disconnected = 1;
|
||||||
txt->client_org_on_disconnect (sck);
|
txt->client_org_on_disconnect (sck);
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ static int txt_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
txt_t* txt = (txt_t*)cli->rsrc;
|
txt_t* txt = (txt_t*)cli->task;
|
||||||
|
|
||||||
HIO_ASSERT (hio, sck == cli->sck);
|
HIO_ASSERT (hio, sck == cli->sck);
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ static int txt_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrc
|
|||||||
{
|
{
|
||||||
hio_t* hio = sck->hio;
|
hio_t* hio = sck->hio;
|
||||||
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
|
||||||
txt_t* txt = (txt_t*)cli->rsrc;
|
txt_t* txt = (txt_t*)cli->task;
|
||||||
|
|
||||||
if (wrlen <= -1)
|
if (wrlen <= -1)
|
||||||
{
|
{
|
||||||
@ -329,7 +329,7 @@ int hio_svc_htts_dotxt (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
/* ensure that you call this function before any contents is received */
|
/* ensure that you call this function before any contents is received */
|
||||||
HIO_ASSERT (hio, hio_htre_getcontentlen(req) == 0);
|
HIO_ASSERT (hio, hio_htre_getcontentlen(req) == 0);
|
||||||
|
|
||||||
txt = (txt_t*)hio_svc_htts_rsrc_make(htts, HIO_SIZEOF(*txt), txt_on_kill);
|
txt = (txt_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*txt), txt_on_kill);
|
||||||
if (HIO_UNLIKELY(!txt)) goto oops;
|
if (HIO_UNLIKELY(!txt)) goto oops;
|
||||||
|
|
||||||
txt->options = options;
|
txt->options = options;
|
||||||
@ -345,8 +345,8 @@ int hio_svc_htts_dotxt (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
|
|||||||
csck->on_write = txt_client_on_write;
|
csck->on_write = txt_client_on_write;
|
||||||
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->task == HIO_NULL);
|
||||||
HIO_SVC_HTTS_RSRC_REF ((hio_svc_htts_rsrc_t*)txt, cli->rsrc);
|
HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)txt, cli->task);
|
||||||
|
|
||||||
if (req->flags & HIO_HTRE_ATTR_EXPECT100)
|
if (req->flags & HIO_HTRE_ATTR_EXPECT100)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user