fixed a bug in handling sendfile in mio.c
This commit is contained in:
parent
8655269e07
commit
fc74064984
@ -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 (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;
|
if (file_state_sendfile_to_client(file_state, file_state->cur_offset, lim) <= -1) return -1;
|
||||||
file_state->cur_offset += lim;
|
file_state->cur_offset += lim;
|
||||||
}
|
}
|
||||||
|
@ -468,13 +468,20 @@ static MIO_INLINE void handle_event (mio_t* mio, mio_dev_t* dev, int events, int
|
|||||||
else if (x == 0)
|
else if (x == 0)
|
||||||
{
|
{
|
||||||
/* keep the left-over */
|
/* keep the left-over */
|
||||||
MIO_MEMMOVE (q->ptr, uptr, urem);
|
if (!q->sendfile) MIO_MEMMOVE (q->ptr, uptr, urem);
|
||||||
q->len = urem;
|
q->len = urem;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (q->sendfile)
|
||||||
|
{
|
||||||
|
((wq_sendfile_data_t*)(q->ptr))->foff += ulen;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
uptr += ulen;
|
uptr += ulen;
|
||||||
|
}
|
||||||
urem -= ulen;
|
urem -= ulen;
|
||||||
|
|
||||||
if (urem <= 0)
|
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 */
|
return 1; /* written immediately and called on_write callback. but this line will never be reached */
|
||||||
|
|
||||||
enqueue_data:
|
enqueue_data:
|
||||||
printf ("queueing sendfiel...\n");
|
|
||||||
return __enqueue_pending_sendfile(dev, len, urem, uoff, in_fd, tmout, wrctx, MIO_NULL);
|
return __enqueue_pending_sendfile(dev, len, urem, uoff, in_fd, tmout, wrctx, MIO_NULL);
|
||||||
|
|
||||||
enqueue_completed_write:
|
enqueue_completed_write:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user