fixed a bug in handling sendfile in mio.c

This commit is contained in:
hyung-hwan 2020-07-19 16:19:18 +00:00
parent 8655269e07
commit fc74064984
2 changed files with 10 additions and 4 deletions

View File

@ -490,7 +490,7 @@ static int file_state_send_contents_to_client (file_state_t* file_state)
if (1 /*mio_dev_sck_sendfileok(file_state->client->sck)*/)
{
if (lim > 0xFFFF) lim = 0xFFFF; /* TODO: change this... */
if (lim > 0x7FFF0000) lim = 0x7FFF0000; /* TODO: change this... */
if (file_state_sendfile_to_client(file_state, file_state->cur_offset, lim) <= -1) return -1;
file_state->cur_offset += lim;
}

View File

@ -468,13 +468,20 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int
else if (x == 0)
{
/* keep the left-over */
MIO_MEMMOVE (q->ptr, uptr, urem);
if (!q->sendfile) MIO_MEMMOVE (q->ptr, uptr, urem);
q->len = urem;
break;
}
else
{
if (q->sendfile)
{
((wq_sendfile_data_t*)(q->ptr))->foff += ulen;
}
else
{
uptr += ulen;
}
urem -= ulen;
if (urem <= 0)
@ -1720,7 +1727,6 @@ static int __dev_sendfile (mio_dev_t* dev, mio_syshnd_t in_fd, mio_foff_t foff,
return 1; /* written immediately and called on_write callback. but this line will never be reached */
enqueue_data:
printf ("queueing sendfiel...\n");
return __enqueue_pending_sendfile(dev, len, urem, uoff, in_fd, tmout, wrctx, MIO_NULL);
enqueue_completed_write: