* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.h,v 1.51 2001/01/09 21:57:34 bwelling Exp $ */
+/* $Id: socket.h,v 1.52 2001/01/26 23:17:25 bwelling Exp $ */
#ifndef ISC_SOCKET_H
#define ISC_SOCKET_H 1
#define ISC_SOCKEVENT_SENDDONE (ISC_EVENTCLASS_SOCKET + 2)
#define ISC_SOCKEVENT_NEWCONN (ISC_EVENTCLASS_SOCKET + 3)
#define ISC_SOCKEVENT_CONNECT (ISC_EVENTCLASS_SOCKET + 4)
-#define ISC_SOCKEVENT_RECVMARK (ISC_EVENTCLASS_SOCKET + 5)
-#define ISC_SOCKEVENT_SENDMARK (ISC_EVENTCLASS_SOCKET + 6)
/*
* Internal events.
* XXX needs other net-type errors
*/
-isc_result_t
-isc_socket_recvmark(isc_socket_t *sock, isc_task_t *task,
- isc_taskaction_t action, const void *arg);
-isc_result_t
-isc_socket_sendmark(isc_socket_t *sock, isc_task_t *task,
- isc_taskaction_t action, const void *arg);
-/*
- * Insert a recv/send marker for the socket.
- *
- * This marker is processed when all I/O requests in the proper queue
- * have been processed.
- *
- * Requires:
- *
- * 'socket' is a valid, bound socket.
- *
- * 'task' is a valid task, 'action' is a valid action.
- *
- * Notes:
- *
- * If the queue is empty, the event will be posted immediately to the
- * task.
- *
- * On return, the event's 'result' member will sometimes contain useful
- * information. If the mark was processed after a fatal error, it will
- * contain the same error that the last isc_socket_recv(), _send(),
- * or sendto() returned, depending on the mark type.
- *
- * Returns:
- *
- * ISC_R_SUCCESS
- * ISC_R_NOMEMORY
- * ISC_R_UNEXPECTED
- */
-
isc_result_t
isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
/*
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: socket.c,v 1.184 2001/01/25 22:25:10 neild Exp $ */
+/* $Id: socket.c,v 1.185 2001/01/26 23:17:26 bwelling Exp $ */
#include <config.h>
/*
* Try to do as much I/O as possible on this socket. There are no
- * limits here, currently. If some sort of quantum read count is
- * desired before giving up control, make certain to process markers
- * regardless of quantum.
+ * limits here, currently.
*/
dev = ISC_LIST_HEAD(sock->recv_list);
while (dev != NULL) {
- /*
- * If this is a marker event, post its completion and
- * continue the loop.
- */
- if (dev->ev_type == ISC_SOCKEVENT_RECVMARK) {
- send_recvdone_event(sock, &dev, ISC_R_SUCCESS);
- goto next;
- }
-
switch (doio_recv(sock, dev)) {
case DOIO_SOFT:
goto poke;
/*
* read of 0 means the remote end was closed.
* Run through the event queue and dispatch all
- * the events with an EOF result code. This will
- * set the EOF flag in markers as well, but
- * that's really ok.
+ * the events with an EOF result code.
*/
do {
send_recvdone_event(sock, &dev, ISC_R_EOF);
/*
* Try to do as much I/O as possible on this socket. There are no
- * limits here, currently. If some sort of quantum write count is
- * desired before giving up control, make certain to process markers
- * regardless of quantum.
+ * limits here, currently.
*/
dev = ISC_LIST_HEAD(sock->send_list);
while (dev != NULL) {
- /*
- * If this is a marker event, post its completion and
- * continue the loop.
- */
- if (dev->ev_type == ISC_SOCKEVENT_SENDMARK) {
- send_senddone_event(sock, &dev, ISC_R_SUCCESS);
- goto next;
- }
-
switch (doio_send(sock, dev)) {
case DOIO_SOFT:
goto poke;
UNLOCK(&sock->lock);
}
-isc_result_t
-isc_socket_recvmark(isc_socket_t *sock,
- isc_task_t *task, isc_taskaction_t action, const void *arg)
-{
- isc_socketevent_t *dev;
- isc_socketmgr_t *manager;
- isc_task_t *ntask = NULL;
-
- REQUIRE(VALID_SOCKET(sock));
- REQUIRE(task != NULL);
- REQUIRE(action != NULL);
-
- manager = sock->manager;
- REQUIRE(VALID_MANAGER(manager));
-
- LOCK(&sock->lock);
-
- INSIST(sock->bound);
-
- dev = allocate_socketevent(sock, ISC_SOCKEVENT_RECVMARK, action, arg);
- if (dev == NULL) {
- UNLOCK(&sock->lock);
- return (ISC_R_NOMEMORY);
- }
-
- dev->result = ISC_R_SUCCESS;
- dev->minimum = 0;
-
- /*
- * Bad luck. The queue wasn't empty. Insert this in the proper
- * place.
- */
- isc_task_attach(task, &ntask);
-
- dev->ev_sender = ntask;
-
- ISC_LIST_ENQUEUE(sock->recv_list, dev, ev_link);
-
- socket_log(sock, NULL, EVENT, NULL, 0, 0,
- "isc_socket_recvmark: event %p -> task %p", dev, ntask);
-
- UNLOCK(&sock->lock);
- return (ISC_R_SUCCESS);
-}
-
-isc_result_t
-isc_socket_sendmark(isc_socket_t *sock,
- isc_task_t *task, isc_taskaction_t action, const void *arg)
-{
- isc_socketevent_t *dev;
- isc_socketmgr_t *manager;
- isc_task_t *ntask = NULL;
-
- REQUIRE(VALID_SOCKET(sock));
- REQUIRE(task != NULL);
- REQUIRE(action != NULL);
-
- manager = sock->manager;
- REQUIRE(VALID_MANAGER(manager));
-
- LOCK(&sock->lock);
-
- INSIST(sock->bound);
-
- dev = allocate_socketevent(sock, ISC_SOCKEVENT_SENDMARK, action, arg);
- if (dev == NULL) {
- UNLOCK(&sock->lock);
- return (ISC_R_NOMEMORY);
- }
-
- dev->result = ISC_R_SUCCESS;
- dev->minimum = 0;
-
- /*
- * Bad luck. The queue wasn't empty. Insert this in the proper
- * place.
- */
- isc_task_attach(task, &ntask);
-
- dev->ev_sender = ntask;
-
- ISC_LIST_ENQUEUE(sock->send_list, dev, ev_link);
-
- socket_log(sock, NULL, EVENT, NULL, 0, 0,
- "isc_socket_sendmark: event %p -> task %p", dev, ntask);
-
- UNLOCK(&sock->lock);
- return (ISC_R_SUCCESS);
-}
-
isc_sockettype_t
isc_socket_gettype(isc_socket_t *sock) {
REQUIRE(VALID_SOCKET(sock));