Commit d9c920ac authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(isc_flush): Handle struct isc_scb_internal.

(write_cb): Handle struct isc_scb_internal.
(isc_oflush): Handle struct isc_scb_internal.
parent 644320e2
......@@ -56,20 +56,22 @@
void isc_flush(struct isc_scb *scb)
{
switch (scb->state)
struct isc_scb_internal *sci = (struct isc_scb_internal*)scb;
switch (sci->state)
{
case ISC_STATE_CLOSING:
if (scb->wr_msg_q)
if (sci->wr_msg_q)
{
isc_killqueue(scb->wr_msg_q);
scb->wr_msg_q = NULL;
isc_killqueue(sci->wr_msg_q);
sci->wr_msg_q = NULL;
}
scb->sendindex = 0;
sci->sendindex = 0;
return;
case ISC_STATE_RUNNING:
case ISC_STATE_DISABLED:
isc_oflush(scb);
isc_oflush(sci);
return;
default:
......@@ -83,9 +85,9 @@ write_cb(oop_source *src,
oop_event event,
void *user)
{
struct isc_scb *scb = user;
assert(scb->fd == fd);
assert(scb->master->event_source == src);
struct isc_scb_internal *scb = user;
assert(scb->pub.fd == fd);
assert(scb->pub.master->event_source == src);
assert(event == OOP_WRITE);
isc_oflush(scb);
......@@ -94,7 +96,7 @@ write_cb(oop_source *src,
void
isc_oflush(struct isc_scb *scb)
isc_oflush(struct isc_scb_internal *scb)
{
struct isc_msg * msg;
int failed;
......@@ -114,7 +116,7 @@ isc_oflush(struct isc_scb *scb)
scb->sendindex = 0;
}
if (scb->fd == -1)
if (scb->pub.fd == -1)
return;
/* Queued entries? Send as much as possible */
......@@ -123,7 +125,7 @@ isc_oflush(struct isc_scb *scb)
while ((msg = isc_topqueue(scb->wr_msg_q)) != NULL &&
!failed && loopcnt < scb->cfg->max.dequeuelen)
{
wlen = write(scb->fd, msg->buffer, msg->length);
wlen = write(scb->pub.fd, msg->buffer, msg->length);
if (wlen < 0)
{
......@@ -134,12 +136,14 @@ isc_oflush(struct isc_scb *scb)
break;
case EPIPE:
scb->write_err_cb(scb->master, scb, errno, scb->data_available_user);
scb->write_err_cb(scb->pub.master, &scb->pub,
errno, scb->data_available_user);
scb->state = ISC_STATE_CLOSING;
return;
default:
scb->write_err_cb(scb->master, scb, errno, scb->data_available_user);
scb->write_err_cb(scb->pub.master, &scb->pub,
errno, scb->data_available_user);
scb->state = ISC_STATE_CLOSING;
scb->sendindex = 0;
return;
......@@ -170,8 +174,8 @@ isc_oflush(struct isc_scb *scb)
{
if (!scb->write_cb_registered)
{
src = scb->master->event_source;
src->on_fd(src, scb->fd, OOP_WRITE, write_cb, scb);
src = scb->pub.master->event_source;
src->on_fd(src, scb->pub.fd, OOP_WRITE, write_cb, scb);
scb->write_cb_registered = 1;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment