*/
dev = ISC_LIST_HEAD(sock->accept_list);
if (dev == NULL) {
+ unwatch_fd(thread, sock->fd, SELECT_POKE_ACCEPT);
UNLOCK(&sock->lock);
return;
}
/*
* Poke watcher if there are more pending accepts.
*/
- if (!ISC_LIST_EMPTY(sock->accept_list))
- watch_fd(thread, sock->fd,
- SELECT_POKE_ACCEPT);
+ if (ISC_LIST_EMPTY(sock->accept_list))
+ unwatch_fd(thread, sock->fd,
+ SELECT_POKE_ACCEPT);
UNLOCK(&sock->lock);
LOCK(&sock->lock);
dev = ISC_LIST_HEAD(sock->recv_list);
if (dev == NULL) {
- UNLOCK(&sock->lock);
+ goto finish;
return;
}
while (dev != NULL) {
switch (doio_recv(sock, dev)) {
case DOIO_SOFT:
- goto poke;
+ goto finish;
case DOIO_EOF:
/*
send_recvdone_event(sock, &dev);
dev = ISC_LIST_HEAD(sock->recv_list);
} while (dev != NULL);
- goto poke;
+ goto finish;
case DOIO_SUCCESS:
case DOIO_HARD:
dev = ISC_LIST_HEAD(sock->recv_list);
}
- poke:
- if (!ISC_LIST_EMPTY(sock->recv_list))
- watch_fd(&sock->manager->threads[sock->threadid], sock->fd,
- SELECT_POKE_READ);
-
+ finish:
+ if (ISC_LIST_EMPTY(sock->recv_list))
+ unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd,
+ SELECT_POKE_READ);
UNLOCK(&sock->lock);
}
LOCK(&sock->lock);
dev = ISC_LIST_HEAD(sock->send_list);
if (dev == NULL) {
- UNLOCK(&sock->lock);
- return;
+ goto finish;
}
socket_log(sock, NULL, EVENT, NULL, 0, 0,
"internal_send: event %p -> task %p",
while (dev != NULL) {
switch (doio_send(sock, dev)) {
case DOIO_SOFT:
- goto poke;
+ goto finish;
case DOIO_HARD:
case DOIO_SUCCESS:
dev = ISC_LIST_HEAD(sock->send_list);
}
- poke:
- if (!ISC_LIST_EMPTY(sock->send_list))
- watch_fd(&sock->manager->threads[sock->threadid], sock->fd, SELECT_POKE_WRITE);
-
+ finish:
+ if (ISC_LIST_EMPTY(sock->send_list))
+ unwatch_fd(&sock->manager->threads[sock->threadid],
+ sock->fd, SELECT_POKE_WRITE);
UNLOCK(&sock->lock);
}
bool writeable)
{
isc__socket_t *sock;
- bool unwatch_read = false, unwatch_write = false;
int lockid = FDLOCK_ID(fd);
/*
sock = thread->fds[fd];
if (sock == NULL) {
- unwatch_read = readable;
- unwatch_write = writeable;
- goto unlock_fd;
+ UNLOCK(&thread->fdlock[lockid]);
+ return;
}
if (SOCK_DEAD(sock)) { /* Sock is being closed, bail */
goto unlock_fd;
internal_accept(sock);
else
internal_recv(sock);
- unwatch_read = true;
}
if (writeable) {
internal_connect(sock);
else
internal_send(sock);
- unwatch_write = true;
}
unlock_fd:
UNLOCK(&thread->fdlock[lockid]);
- if (unwatch_read)
- (void)unwatch_fd(thread, fd, SELECT_POKE_READ);
- if (unwatch_write)
- (void)unwatch_fd(thread, fd, SELECT_POKE_WRITE);
if (sock != NULL) {
if (isc_refcount_decrement(&sock->references) == 1) {
destroy(&sock);
* Enqueue the request. If the socket was previously not being
* watched, poke the watcher to start paying attention to it.
*/
- if (ISC_LIST_EMPTY(sock->recv_list))
+ bool do_poke = ISC_LIST_EMPTY(sock->recv_list);
+ ISC_LIST_ENQUEUE(sock->recv_list, dev, ev_link);
+ if (do_poke) {
select_poke(sock->manager, sock->threadid, sock->fd,
SELECT_POKE_READ);
- ISC_LIST_ENQUEUE(sock->recv_list, dev, ev_link);
+ }
socket_log(sock, NULL, EVENT, NULL, 0, 0,
"socket_recv: event %p -> task %p",
* not being watched, poke the watcher to start
* paying attention to it.
*/
- if (ISC_LIST_EMPTY(sock->send_list))
+ bool do_poke = ISC_LIST_EMPTY(sock->send_list);
+ ISC_LIST_ENQUEUE(sock->send_list, dev, ev_link);
+ if (do_poke) {
select_poke(sock->manager, sock->threadid,
sock->fd,
SELECT_POKE_WRITE);
- ISC_LIST_ENQUEUE(sock->send_list, dev, ev_link);
-
+ }
socket_log(sock, NULL, EVENT, NULL, 0, 0,
"socket_send: event %p -> task %p",
dev, ntask);
* is no race condition. We will keep the lock for such a short
* bit of time waking it up now or later won't matter all that much.
*/
- if (ISC_LIST_EMPTY(sock->accept_list))
- do_poke = true;
-
+ do_poke = ISC_LIST_EMPTY(sock->accept_list);
ISC_LIST_ENQUEUE(sock->accept_list, dev, ev_link);
-
- if (do_poke)
+ if (do_poke) {
select_poke(manager, sock->threadid, sock->fd,
SELECT_POKE_ACCEPT);
-
+ }
UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
}
* is no race condition. We will keep the lock for such a short
* bit of time waking it up now or later won't matter all that much.
*/
- if (ISC_LIST_EMPTY(sock->connect_list) && !sock->connecting)
+ bool do_poke = ISC_LIST_EMPTY(sock->connect_list);
+ ISC_LIST_ENQUEUE(sock->connect_list, dev, ev_link);
+ if (do_poke && !sock->connecting) {
+ sock->connecting = 1;
select_poke(manager, sock->threadid, sock->fd,
SELECT_POKE_CONNECT);
-
- sock->connecting = 1;
-
- ISC_LIST_ENQUEUE(sock->connect_list, dev, ev_link);
+ }
UNLOCK(&sock->lock);
return (ISC_R_SUCCESS);
dev = ISC_LIST_HEAD(sock->connect_list);
if (dev == NULL) {
INSIST(!sock->connecting);
- UNLOCK(&sock->lock);
- return;
+ goto finish;
}
INSIST(sock->connecting);
*/
if (SOFT_ERROR(errno) || errno == EINPROGRESS) {
sock->connecting = 1;
- watch_fd(&sock->manager->threads[sock->threadid], sock->fd,
- SELECT_POKE_CONNECT);
UNLOCK(&sock->lock);
-
return;
}
dev = ISC_LIST_HEAD(sock->connect_list);
} while (dev != NULL);
+ finish:
+ unwatch_fd(&sock->manager->threads[sock->threadid], sock->fd,
+ SELECT_POKE_CONNECT);
+
UNLOCK(&sock->lock);
}
TRY0(xmlTextWriterStartElement(writer,
ISC_XMLCHAR "references"));
TRY0(xmlTextWriterWriteFormatString(writer, "%d",
- isc_refcount_current(&sock->references)));
+ (int)isc_refcount_current(&sock->references)));
TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterWriteElement(writer, ISC_XMLCHAR "type",
json_object_object_add(entry, "name", obj);
}
- obj = json_object_new_int(isc_refcount_current(&sock->references));
+ obj = json_object_new_int((int)isc_refcount_current(&sock->references));
CHECKMEM(obj);
json_object_object_add(entry, "references", obj);