moved up the ioctl field in hio_dev_mth_t

This commit is contained in:
hyung-hwan 2021-08-08 07:37:33 +00:00
parent 53ddebff6d
commit 317dbfebfd
10 changed files with 33 additions and 31 deletions

View File

@ -225,6 +225,9 @@ struct hio_dev_mth_t
hio_syshnd_t (*getsyshnd) (hio_dev_t* dev); /* mandatory. called in hio_dev_make() after successful make() */
int (*issyshndbroken) (hio_dev_t* dev); /* the device whose underlying system handle can get closed before kill() must implement this */
/* ------------------------------------------------------------------ */
int (*ioctl) (hio_dev_t* dev, int cmd, void* arg);
/* ------------------------------------------------------------------ */
/* return -1 on failure, 0 if no data is availble, 1 otherwise.
* when returning 1, *len must be sent to the length of data read.
@ -235,10 +238,6 @@ struct hio_dev_mth_t
int (*write) (hio_dev_t* dev, const void* data, hio_iolen_t* len, const hio_devaddr_t* dstaddr);
int (*writev) (hio_dev_t* dev, const hio_iovec_t* iov, hio_iolen_t* iovcnt, const hio_devaddr_t* dstaddr);
int (*sendfile) (hio_dev_t* dev, hio_syshnd_t in_fd, hio_foff_t foff, hio_iolen_t* len);
/* ------------------------------------------------------------------ */
int (*ioctl) (hio_dev_t* dev, int cmd, void* arg);
};
struct hio_dev_evcb_t

View File

@ -228,7 +228,7 @@ static HIO_INLINE void cgi_mark_over (cgi_t* cgi, int over_bits)
/* 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);
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);
/* cgi must not be access from here down as it could have been destroyed */
}
@ -317,7 +317,7 @@ static void cgi_peer_on_close (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid)
cgi->peer = HIO_NULL; /* clear this peer from the state */
HIO_ASSERT (hio, cgi_peer->state != HIO_NULL);
printf ("DETACHING FROM CGI PEER DEVICE.....................%p %d\n", cgi_peer->state, (int)cgi_peer->state->rsrc_refcnt);
/*printf ("DETACHING FROM CGI PEER DEVICE.....................%p %d\n", cgi_peer->state, (int)cgi_peer->state->rsrc_refcnt);*/
HIO_SVC_HTTS_RSRC_DETACH (cgi_peer->state);
if (cgi->peer_htrd)
@ -326,7 +326,7 @@ printf ("DETACHING FROM CGI PEER DEVICE.....................%p %d\n", cgi_peer
* it's safe to detach the extra information attached on the htrd object. */
cgi_peer = hio_htrd_getxtn(cgi->peer_htrd);
HIO_ASSERT (hio, cgi_peer->state != HIO_NULL);
printf ("DETACHING FROM CGI PEER HTRD.....................%p %d\n", cgi_peer->state, (int)cgi_peer->state->rsrc_refcnt);
/*printf ("DETACHING FROM CGI PEER HTRD.....................%p %d\n", cgi_peer->state, (int)cgi_peer->state->rsrc_refcnt);*/
HIO_SVC_HTTS_RSRC_DETACH (cgi_peer->state);
}
@ -407,7 +407,7 @@ static int cgi_peer_on_read (hio_dev_pro_t* pro, hio_dev_pro_sid_t sid, const vo
if (rem > 0)
{
/* If the script specifies Content-Length and produces longer data, it will come here */
printf ("AAAAAAAAAAAAAAAAAa EEEEEXcessive DATA..................\n");
/*printf ("AAAAAAAAAAAAAAAAAa EEEEEXcessive DATA..................\n");*/
/* TODO: or drop this request?? */
}
}
@ -472,7 +472,7 @@ static int cgi_peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req)
if (*endptr == '\0' && is_sober && v > 0 && v <= HIO_TYPE_MAX(int)) status_code = v;
}
printf ("CGI PEER HTRD PEEK...\n");
/*printf ("CGI PEER HTRD PEEK...\n");*/
hio_svc_htts_fmtgmtime (cli->htts, HIO_NULL, dtbuf, HIO_COUNTOF(dtbuf));
if (hio_becs_fmt(cli->sbuf, "HTTP/%d.%d %d %hs\r\nServer: %hs\r\nDate: %hs\r\n",
@ -508,7 +508,7 @@ static int cgi_peer_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
cgi_peer_xtn_t* cgi_peer = hio_htrd_getxtn(htrd);
cgi_t* cgi = cgi_peer->state;
printf (">> PEER RESPONSE COMPLETED\n");
/*printf (">> PEER RESPONSE COMPLETED\n");*/
if (cgi_write_last_chunk_to_client(cgi) <= -1) return -1;
@ -580,7 +580,7 @@ static int cgi_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
cgi_t* cgi = (cgi_t*)cli->rsrc;
printf (">> CLIENT REQUEST COMPLETED\n");
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
/* indicate EOF to the client peer */
if (cgi_write_to_peer(cgi, HIO_NULL, 0) <= -1) return -1;

View File

@ -407,7 +407,7 @@ static int thr_peer_on_read (hio_dev_thr_t* thr, const void* data, hio_iolen_t d
if (rem > 0)
{
/* If the script specifies Content-Length and produces longer data, it will come here */
printf ("AAAAAAAAAAAAAAAAAa EEEEEXcessive DATA..................\n");
/*printf ("AAAAAAAAAAAAAAAAAa EEEEEXcessive DATA..................\n");*/
/* TODO: or drop this request?? */
}
}

View File

@ -140,7 +140,7 @@ static HIO_INLINE void txt_mark_over (txt_t* txt, int over_bits)
/* 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);
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);
/* txt must not be access from here down as it could have been destroyed */
}
@ -204,7 +204,7 @@ static int txt_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
txt_t* txt = (txt_t*)cli->rsrc;
printf (">> CLIENT REQUEST COMPLETED\n");
/*printf (">> CLIENT REQUEST COMPLETED\n");*/
txt_mark_over (txt, TXT_OVER_READ_FROM_CLIENT);
return 0;
@ -267,7 +267,7 @@ static int txt_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
if (rem > 0)
{
/* TODO store this to client buffer. once the current resource is completed, arrange to call on_read() with it */
printf ("UUUUUUUUUUUUUUUUUUUUUUUUUUGGGGGHHHHHHHHHHHH .......... TXT CLIENT GIVING EXCESSIVE DATA AFTER CONTENTS...\n");
/*printf ("UUUUUUUUUUUUUUUUUUUUUUUUUUGGGGGHHHHHHHHHHHH .......... TXT CLIENT GIVING EXCESSIVE DATA AFTER CONTENTS...\n");*/
}
}

View File

@ -355,12 +355,12 @@ static hio_dev_mth_t dev_mar_methods =
HIO_NULL,
dev_mar_getsyshnd,
dev_mar_issyshndbroken,
dev_mar_ioctl,
HIO_NULL,
HIO_NULL,
HIO_NULL,
HIO_NULL, /* sendfile */
dev_mar_ioctl
};
/* ========================================================================= */

View File

@ -377,11 +377,12 @@ static hio_dev_mth_t dev_pipe_methods =
HIO_NULL,
dev_pipe_getsyshnd,
HIO_NULL,
dev_pipe_ioctl,
HIO_NULL,
HIO_NULL,
HIO_NULL,
dev_pipe_ioctl
HIO_NULL, /* sendfile */
};
static hio_dev_mth_t dev_pipe_methods_slave =
@ -391,11 +392,12 @@ static hio_dev_mth_t dev_pipe_methods_slave =
dev_pipe_fail_before_make_slave,
dev_pipe_getsyshnd_slave,
HIO_NULL,
dev_pipe_ioctl,
dev_pipe_read_slave,
dev_pipe_write_slave,
dev_pipe_writev_slave,
dev_pipe_ioctl
HIO_NULL, /* sendfile */
};
/* ========================================================================= */

View File

@ -739,12 +739,12 @@ static hio_dev_mth_t dev_pro_methods =
HIO_NULL,
dev_pro_getsyshnd,
HIO_NULL,
dev_pro_ioctl,
HIO_NULL, /* read */
HIO_NULL, /* write */
HIO_NULL, /* writev */
HIO_NULL, /* sendfile */
dev_pro_ioctl
};
static hio_dev_mth_t dev_pro_methods_slave =
@ -754,12 +754,12 @@ static hio_dev_mth_t dev_pro_methods_slave =
HIO_NULL,
dev_pro_getsyshnd_slave,
HIO_NULL,
dev_pro_ioctl,
dev_pro_read_slave,
dev_pro_write_slave,
dev_pro_writev_slave,
HIO_NULL, /* sendfile */
dev_pro_ioctl
};
/* ========================================================================= */

View File

@ -1531,12 +1531,12 @@ static hio_dev_mth_t dev_mth_sck_stateless =
HIO_NULL,
dev_sck_getsyshnd,
HIO_NULL,
dev_sck_ioctl, /* ioctl */
dev_sck_read_stateless,
dev_sck_write_stateless,
dev_sck_writev_stateless,
HIO_NULL, /* sendfile */
dev_sck_ioctl, /* ioctl */
};
@ -1547,12 +1547,12 @@ static hio_dev_mth_t dev_mth_sck_stream =
HIO_NULL,
dev_sck_getsyshnd,
HIO_NULL,
dev_sck_ioctl, /* ioctl */
dev_sck_read_stream,
dev_sck_write_stream,
dev_sck_writev_stream,
dev_sck_sendfile_stream,
dev_sck_ioctl, /* ioctl */
};
static hio_dev_mth_t dev_mth_clisck_stateless =
@ -1562,12 +1562,12 @@ static hio_dev_mth_t dev_mth_clisck_stateless =
dev_sck_fail_before_make_client,
dev_sck_getsyshnd,
HIO_NULL,
dev_sck_ioctl,
dev_sck_read_stateless,
dev_sck_write_stateless,
dev_sck_writev_stateless,
HIO_NULL,
dev_sck_ioctl
};
static hio_dev_mth_t dev_mth_clisck_stream =
@ -1577,12 +1577,12 @@ static hio_dev_mth_t dev_mth_clisck_stream =
dev_sck_fail_before_make_client,
dev_sck_getsyshnd,
HIO_NULL,
dev_sck_ioctl,
dev_sck_read_stream,
dev_sck_write_stream,
dev_sck_writev_stream,
dev_sck_sendfile_stream,
dev_sck_ioctl
dev_sck_sendfile_stream
};
static hio_dev_mth_t dev_mth_sck_bpf =
@ -1592,12 +1592,12 @@ static hio_dev_mth_t dev_mth_sck_bpf =
HIO_NULL,
dev_sck_getsyshnd,
HIO_NULL,
dev_sck_ioctl, /* ioctl */
dev_sck_read_bpf,
dev_sck_write_bpf,
dev_sck_writev_bpf,
HIO_NULL, /* sendfile */
dev_sck_ioctl, /* ioctl */
};
/* ========================================================================= */

View File

@ -75,9 +75,10 @@ void hio_sys_fini (hio_t* hio)
}
/* TODO: migrate this function */
/* TODO: migrate these functions */
#include <fcntl.h>
#include <errno.h>
int hio_makesyshndasync (hio_t* hio, hio_syshnd_t hnd)
{
#if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK)
@ -86,7 +87,6 @@ int hio_makesyshndasync (hio_t* hio, hio_syshnd_t hnd)
if ((flags = fcntl(hnd, F_GETFL, 0)) <= -1 ||
fcntl(hnd, F_SETFL, flags | O_NONBLOCK) <= -1)
{
printf ("make sysnhd async error (%d) - errno %d\n", hnd, errno);
hio_seterrwithsyserr (hio, 0, errno);
return -1;
}
@ -106,7 +106,6 @@ int hio_makesyshndcloexec (hio_t* hio, hio_syshnd_t hnd)
if ((flags = fcntl(hnd, F_GETFD, 0)) <= -1 ||
fcntl(hnd, F_SETFD, flags | FD_CLOEXEC) <= -1)
{
printf ("make sysnhd cloexec error (%d) - errno %d\n", hnd, errno);
hio_seterrwithsyserr (hio, 0, errno);
return -1;
}

View File

@ -569,11 +569,12 @@ static hio_dev_mth_t dev_thr_methods =
HIO_NULL,
dev_thr_getsyshnd,
HIO_NULL,
dev_thr_ioctl,
HIO_NULL,
HIO_NULL,
HIO_NULL,
dev_thr_ioctl
HIO_NULL /* sendfile */
};
static hio_dev_mth_t dev_thr_methods_slave =
@ -583,11 +584,12 @@ static hio_dev_mth_t dev_thr_methods_slave =
dev_thr_fail_before_make_slave,
dev_thr_getsyshnd_slave,
HIO_NULL,
dev_thr_ioctl,
dev_thr_read_slave,
dev_thr_write_slave,
dev_thr_writev_slave,
dev_thr_ioctl
HIO_NULL, /* sendfile */
};
/* ========================================================================= */