made minor changes
This commit is contained in:
parent
57ca185651
commit
98e2838edf
@ -863,6 +863,14 @@ int mio_svc_htts_dofile (mio_svc_htts_t* htts, mio_dev_sck_t* csck, mio_htre_t*
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
|
enum cgi_state_res_mode_t
|
||||||
|
{
|
||||||
|
CGI_STATE_RES_MODE_CHUNKED,
|
||||||
|
CGI_STATE_RES_MODE_CLOSE
|
||||||
|
/* CGI_STATE_RES_MODE_LENGTH */
|
||||||
|
};
|
||||||
|
typedef enum cgi_state_res_mode_t cgi_state_res_mode_t;
|
||||||
|
|
||||||
|
|
||||||
struct cgi_state_t
|
struct cgi_state_t
|
||||||
{
|
{
|
||||||
@ -881,6 +889,8 @@ struct cgi_state_t
|
|||||||
mio_htre_t* req;
|
mio_htre_t* req;
|
||||||
mio_oow_t req_content_length;
|
mio_oow_t req_content_length;
|
||||||
|
|
||||||
|
cgi_state_res_mode_t res_mode_to_cli;
|
||||||
|
|
||||||
mio_dev_sck_on_read_t cli_org_on_read;
|
mio_dev_sck_on_read_t cli_org_on_read;
|
||||||
mio_dev_sck_on_write_t cli_org_on_write;
|
mio_dev_sck_on_write_t cli_org_on_write;
|
||||||
};
|
};
|
||||||
@ -940,26 +950,36 @@ static int cgi_peer_on_read (mio_dev_pro_t* pro, mio_dev_pro_sid_t sid, const vo
|
|||||||
{
|
{
|
||||||
mio_t* mio = pro->mio;
|
mio_t* mio = pro->mio;
|
||||||
cgi_peer_xtn_t* cgi_peer = mio_dev_pro_getxtn(pro);
|
cgi_peer_xtn_t* cgi_peer = mio_dev_pro_getxtn(pro);
|
||||||
|
cgi_state_t* cgi_state = cgi_peer->state;
|
||||||
|
|
||||||
if (dlen <= -1)
|
if (dlen <= -1)
|
||||||
{
|
{
|
||||||
MIO_DEBUG1 (mio, "PROCESS(%d): READ TIMED OUT...\n", (int)pro->child_pid);
|
MIO_DEBUG1 (mio, "PROCESS(%d): READ TIMED OUT...\n", (int)pro->child_pid);
|
||||||
mio_dev_pro_halt (pro);
|
mio_dev_pro_halt (pro);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else if (dlen <= 0)
|
else if (dlen <= 0)
|
||||||
{
|
{
|
||||||
MIO_DEBUG1 (mio, "PROCESS(%d): EOF RECEIVED...\n", (int)pro->child_pid);
|
MIO_DEBUG1 (mio, "PROCESS(%d): EOF RECEIVED...\n", (int)pro->child_pid);
|
||||||
/* no outstanding request. but EOF */
|
/* no outstanding request. but EOF */
|
||||||
|
/* TODO: arrange to finish chunk. or close... also finish the entire state... */
|
||||||
mio_dev_pro_halt (pro);
|
mio_dev_pro_halt (pro);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
MIO_DEBUG5 (mio, "PROCESS(%d) READ DATA ON SLAVE[%d] len=%d [%.*hs]\n", (int)pro->child_pid, (int)sid, (int)dlen, dlen, (char*)data);
|
MIO_DEBUG5 (mio, "PROCESS(%d) READ DATA ON SLAVE[%d] len=%d [%.*hs]\n", (int)pro->child_pid, (int)sid, (int)dlen, dlen, (char*)data);
|
||||||
if (sid == MIO_DEV_PRO_OUT)
|
if (sid == MIO_DEV_PRO_OUT)
|
||||||
{
|
{
|
||||||
mio_dev_pro_read (pro, sid, 0);
|
//mio_dev_pro_read (pro, sid, 0);
|
||||||
mio_dev_pro_write (pro, "HELLO\n", 6, MIO_NULL);
|
//mio_dev_pro_write (pro, "HELLO\n", 6, MIO_NULL);
|
||||||
|
|
||||||
|
/* If chunked, need to write in the chunked format... */
|
||||||
|
cgi_state->num_pending_writes_to_client++;
|
||||||
|
if (mio_dev_sck_write(cgi_state->cli->sck, data, dlen, MIO_NULL, 0) <= -1)
|
||||||
|
{
|
||||||
|
cgi_state->num_pending_writes_to_client--;
|
||||||
|
mio_dev_pro_halt (pro);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -567,12 +567,18 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int
|
|||||||
* is started from within on_read() callback, and the input data is available
|
* is started from within on_read() callback, and the input data is available
|
||||||
* in the next iteration of this loop, the on_read() callback is triggered
|
* in the next iteration of this loop, the on_read() callback is triggered
|
||||||
* before the on_write() callbacks scheduled before that on_read() callback. */
|
* before the on_write() callbacks scheduled before that on_read() callback. */
|
||||||
|
#if 0
|
||||||
if (dev->cw_count > 0)
|
if (dev->cw_count > 0)
|
||||||
{
|
{
|
||||||
fire_cwq_handlers_for_dev (mio, dev);
|
fire_cwq_handlers_for_dev (mio, dev);
|
||||||
/* it will still invoke the on_read() callbak below even if
|
/* it will still invoke the on_read() callbak below even if
|
||||||
* the device gets halted inside fire_cwq_handlers_for_dev() */
|
* the device gets halted inside fire_cwq_handlers_for_dev() */
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
/* currently fire_cwq_handlers_for_dev() scans the entire cwq list.
|
||||||
|
* i might as well triggger handlers for all devices */
|
||||||
|
fire_cwq_handlers (mio);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (len <= 0 && (dev->dev_cap & MIO_DEV_CAP_STREAM))
|
if (len <= 0 && (dev->dev_cap & MIO_DEV_CAP_STREAM))
|
||||||
{
|
{
|
||||||
|
3
mio/t/b.sh
Executable file
3
mio/t/b.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec cat /home/hyung-hwan/projects/hawk/lib/run.c
|
15
mio/t/http1.hawk
Normal file
15
mio/t/http1.hawk
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
BEGIN {
|
||||||
|
|
||||||
|
|
||||||
|
x = sys::socket (sys::AF_INET, sys::SOCK_STREAM, 0);
|
||||||
|
sys::connect (x, "127.0.0.1:9988");
|
||||||
|
|
||||||
|
msg = b"GET /home/hyung-hwan/projects/mio/bld/b.sh HTTP/1.0\r\n\
|
||||||
|
Host: www.google.com\r\n\
|
||||||
|
Connection: Keep-Alive\r\n\r\n";
|
||||||
|
|
||||||
|
|
||||||
|
sys::write (x, msg);
|
||||||
|
while (sys::read (x, buf) >= 0) printf ("%s", buf);
|
||||||
|
sys::close (x);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user