-#ifndef __LWIP_SERVER_SOCKET_H__
-#define __LWIP_SERVER_SOCKET_H__
+#ifndef __NET_SERVER_SOCKET_H__
+#define __NET_SERVER_SOCKET_H__
+
+#include <stdlib.h>
#include <minix/ipc.h>
#include <minix/endpoint.h>
-#include "inet_config.h"
-#include "proto.h"
+/*
+ * User can set this variable to make the debugging output differ between
+ * various users, e.g. "TCP" or "UDP"
+ */
+extern char * netsock_user_name;
#define SOCK_TYPE_IP 0
#define SOCK_TYPE_TCP 1
struct socket;
typedef void (* sock_op_t)(struct socket *, message *);
+typedef void (* sock_op_io_t)(struct socket *, message *, int blk);
typedef int (* sock_op_open_t)(struct socket *, message *);
struct sock_ops {
sock_op_open_t open;
sock_op_t close;
- sock_op_t read;
- sock_op_t write;
- sock_op_t ioctl;
+ sock_op_io_t read;
+ sock_op_io_t write;
+ sock_op_io_t ioctl;
sock_op_t select;
sock_op_t select_reply;
};
};
#define SOCK_FLG_OP_PENDING 0x1
-#define SOCK_FLG_OP_REVIVING 0x2
-#define SOCK_FLG_OP_SUSPENDED 0x4 /* set when processing a suspended op */
+#define SOCK_FLG_OP_IOCTL 0x10
#define SOCK_FLG_OP_LISTENING 0x100 /* tcp socket is in a listening mode */
#define SOCK_FLG_OP_CONNECTING 0x200 /* set when waiting for a connect */
#define SOCK_FLG_OP_READING 0x400 /* reading operation in progress */
#define SOCK_FLG_SEL_WRITE 0x100000
#define SOCK_FLG_SEL_READ 0x200000
#define SOCK_FLG_SEL_ERROR 0x400000
-#define SOCK_FLG_SEL_CHECK 0x800000 /* select satisfied, go and check it */
#define sock_select_set(sock) ((sock)->flags & (SOCK_FLG_SEL_WRITE | \
SOCK_FLG_SEL_READ | SOCK_FLG_SEL_ERROR))
#define sock_select_rw_set(sock) ((sock)->flags & (SOCK_FLG_SEL_READ | \
SOCK_FLG_SEL_WRITE))
#define sock_select_error_set(sock) ((sock)->flags & SOCK_FLG_SEL_ERROR)
-#define sock_select_check_set(sock) ((sock)->flags & SOCK_FLG_SEL_CHECK)
#define sock_clear_select(sock) do { \
(sock)->flags &= ~(SOCK_FLG_SEL_READ | SOCK_FLG_SEL_WRITE | \
- SOCK_FLG_SEL_ERROR | SOCK_FLG_SEL_CHECK); \
+ SOCK_FLG_SEL_ERROR); \
} while (0)
struct socket {
message mess; /* store the message which initiated the
last operation on this socket in case
we have to suspend the operation */
+ void * shm;
+ size_t shm_size;
endpoint_t select_ep;
struct recv_q * recv_head;
struct recv_q * recv_tail;
void * data;
};
-extern struct sock_ops sock_udp_ops;
-extern struct sock_ops sock_tcp_ops;
-extern struct sock_ops sock_raw_ip_ops;
+/*
+ * Each component needs to provide a method how to initially open a socket.
+ * The rest is handled byt the socket library.
+ */
+void socket_open(message * m);
#define get_sock_num(x) ((long int) ((x) - socket))
#define is_valid_sock_num(x) (x < MAX_SOCKETS)
struct socket * get_nic_sock(unsigned dev);
void send_reply(message * m, int status);
+void send_reply_open(message * m, int status);
+void send_reply_close(message * m, int status);
void sock_reply(struct socket * sock, int status);
-void sock_revive(struct socket * sock, int status);
+void sock_reply_close(struct socket * sock, int status);
+void sock_reply_select(struct socket * sock, unsigned selops);
typedef void (* recv_data_free_fn)(void *);
void generic_op_select(struct socket * sock, message * m);
void generic_op_select_reply(struct socket * sock, message * m);
-#endif /* __LWIP_SERVER_SOCKET_H__ */
+int mq_enqueue(message * m);
+
+/* a function thr user has to provide to reply to the posix server */
+void posix_reply(endpoint_t ep, message * m);
+
+#endif /* __NET_SERVER_SOCKET_H__ */
#include <minix/com.h>
#include <minix/callnr.h>
#include <minix/sysutil.h>
+#include <minix/netsock.h>
#include <lwip/tcp.h>
#include <sys/ioc_net.h>
-#include "inet_config.h"
-#include "proto.h"
-#include "socket.h"
+char * netsock_user_name = NULL;
+#define NETSOCK_USER_NAME (netsock_user_name ? netsock_user_name : "NETSOCK")
+
+#define debug_print(str, ...) printf("%s : %s:%d : " str "\n", \
+ NETSOCK_USER_NAME, __func__, __LINE__, ##__VA_ARGS__)
#if 0
-#define debug_sock_print(str, ...) printf("LWIP %s:%d : " str "\n", \
- __func__, __LINE__, ##__VA_ARGS__)
+#define debug_sock_print(...) debug_print(__VA_ARGS__)
#else
-#define debug_sock_print(...) debug_print(__VA_ARGS__)
+#define debug_sock_print(...)
#endif
+#if 0
+#define debug_sock_select_print(...) debug_print(__VA_ARGS__)
+#else
+#define debug_sock_select_print(...) debug_sock_print(__VA_ARGS__)
+#endif
+
+#define netsock_panic(str, ...) panic("%s : " str, NETSOCK_USER_NAME, \
+ ##__VA_ARGS__)
+#define netsock_error(str, ...) printf("%s : " str, NETSOCK_USER_NAME, \
+ ##__VA_ARGS__)
+
struct socket socket[MAX_SOCKETS];
-static int notified;
#define recv_q_alloc() debug_malloc(sizeof(struct recv_q))
#define recv_q_free debug_free
static struct mq * mq_head, *mq_tail;
-static int mq_enqueue(message * m)
+int mq_enqueue(message * m)
{
struct mq * mq;
mq_head->prev = NULL;
} else
mq_head = mq_tail = NULL;
-
+
debug_sock_print("socket %d\n", ret->m.DEVICE);
return ret;
}
}
- mq_dequeue(mq);
- mq_free(mq);
+ if (mq) {
+ mq_dequeue(mq);
+ mq_free(mq);
+ }
return 1;
}
m->REP_IO_GRANT= ref;
}
-void send_reply(message * m, int status)
+void send_reply_type(message * m, int type, int status)
{
int result;
- debug_sock_print("status %d", status);
set_reply_msg(m, status);
-
- m->m_type = TASK_REPLY;
+
+ m->m_type = type;
result = send(m->m_source, m);
if (result != OK)
- panic("LWIP : unable to send (err %d)", result);
+ netsock_panic("unable to send (err %d)", result);
}
-void sock_revive(struct socket * sock, int status)
+void send_reply(message * m, int status)
+{
+ debug_sock_print("status %d", status);
+ send_reply_type(m, DEV_REVIVE, status);
+}
+
+void send_reply_open(message * m, int status)
+{
+ debug_sock_print("status %d", status);
+ send_reply_type(m, DEV_OPEN_REPL, status);
+}
+
+void send_reply_close(message * m, int status)
+{
+ debug_sock_print("status %d", status);
+ send_reply_type(m, DEV_CLOSE_REPL, status);
+}
+
+void sock_reply_select(struct socket * sock, unsigned selops)
{
int result;
+ message msg;
- assert(!(sock->flags & SOCK_FLG_OP_REVIVING));
- assert(sock->flags & (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_SUSPENDED));
+ debug_sock_select_print("selops %d", selops);
- if (notified) {
- debug_sock_print("already notified");
- return;
- }
- else {
- assert(sock->mess.m_type != DEV_REVIVE);
- notified = 1;
- }
-
- debug_sock_print("socket num %ld, status %d",
- get_sock_num(sock), status);
-
- sock->mess.m_type = DEV_REVIVE;
- set_reply_msg(&sock->mess, status);
-
- result = notify(sock->mess.m_source);
- if (result != OK)
- panic("LWIP : unable to notify (err %d)", result);
+ msg.m_type = DEV_SEL_REPL1;
+ msg.DEV_MINOR = get_sock_num(sock);
+ msg.DEV_SEL_OPS = selops;
- sock->flags |= SOCK_FLG_OP_REVIVING;
+ result = send(sock->select_ep, &msg);
+ if (result != OK)
+ netsock_panic("unable to send (err %d)", result);
}
void sock_select_notify(struct socket * sock)
{
int result;
+ message msg;
- debug_sock_print("socket num %ld", get_sock_num(sock));
+ debug_sock_select_print("socket num %ld", get_sock_num(sock));
assert(sock->select_ep != NONE);
- sock->flags |= SOCK_FLG_SEL_CHECK;
- if (notified) {
- debug_sock_print("already notified");
+ msg.DEV_SEL_OPS = 0;
+ sock->ops->select_reply(sock, &msg);
+ if (msg.DEV_SEL_OPS == 0) {
+ debug_sock_select_print("called from %p sflags 0x%x TXsz %d RXsz %d\n",
+ __builtin_return_address(0), sock->flags,
+ sock->buf_size, sock->recv_data_size);
return;
}
- else
- notified = 1;
-
- result = notify(sock->select_ep);
+
+ msg.m_type = DEV_SEL_REPL2;
+ msg.DEV_MINOR = get_sock_num(sock);
+
+ debug_sock_select_print("socket num %d select result 0x%x sent",
+ msg.DEV_MINOR, msg.DEV_SEL_OPS);
+ result = send(sock->select_ep, &msg);
if (result != OK)
- panic("LWIP : unable to notify (err %d)", result);
-}
+ netsock_panic("unable to send (err %d)", result);
-void sock_reply(struct socket * sock, int status)
-{
- debug_sock_print("socket num %ld status %d type %d",
- get_sock_num(sock), status, sock->mess.m_type);
- /*
- * If the status is SUSPEND send the
- * message only if this operation wasn't
- * suspended already, e.g. by enqueing the
- * message when the socket was busy
- * because of another pending message
- *
- * If there is a pending operation or we a reprocessing a suspended
- * operation, revive.
- *
- * Otherwise send a message straightaway
- */
- if (status == SUSPEND) {
- if (sock->flags & SOCK_FLG_OP_SUSPENDED) {
- debug_sock_print("suspended before");
- sock->flags &= ~SOCK_FLG_OP_SUSPENDED;
- return;
- }
- message m = sock->mess;
- debug_sock_print("SUSPEND");
- send_reply(&m, status);
- } else if (sock->flags & (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_SUSPENDED)) {
- sock_revive(sock, status);
- /*
- * From now on, we process suspended calls as any other. The
- * status is set and will be collected
- */
- sock->flags &= ~SOCK_FLG_OP_SUSPENDED;
- } else
- send_reply(&sock->mess, status);
+ sock_clear_select(sock);
+ sock->select_ep = NONE;
}
-struct socket * get_unused_sock(void)
+static void sock_reply_type(struct socket * sock, int type, int status)
{
- int i;
+ sock->mess.m_type = type;
- for (i = SOCK_TYPES + MAX_DEVS; i < MAX_SOCKETS; i++) {
- if (socket[i].ops == NULL) {
- /* clear it all */
- memset(&socket[i], 0, sizeof(struct socket));
- return &socket[i];
- }
- }
-
- return NULL;
+ send_reply_type(&sock->mess, type, status);
}
-struct socket * get_nic_sock(unsigned dev)
+void sock_reply_close(struct socket * sock, int status)
{
- if (dev < MAX_DEVS)
- return &socket[dev + SOCK_TYPES];
- else
- return NULL;
+ debug_sock_print("sock %ld status %d", get_sock_num(sock), status);
+ sock_reply_type(sock, DEV_CLOSE_REPL, status);
}
-static void socket_open(message * m)
+void sock_reply(struct socket * sock, int status)
{
- struct sock_ops * ops;
- struct socket * sock;
- int ret = OK;
-
- switch (m->DEVICE) {
- case SOCK_TYPE_TCP:
- ops = &sock_tcp_ops;
- break;
- case SOCK_TYPE_UDP:
- ops = &sock_udp_ops;
- break;
- case SOCK_TYPE_IP:
- ops = &sock_raw_ip_ops;
- break;
- default:
- if (m->DEVICE - SOCK_TYPES < MAX_DEVS) {
- m->DEVICE -= SOCK_TYPES;
- nic_open(m);
- return;
- }
- printf("LWIP unknown socket type %d\n", m->DEVICE);
- send_reply(m, EINVAL);
- return;
- }
-
- sock = get_unused_sock();
- if (!sock) {
- printf("LWIP : no free socket\n");
- send_reply(m, EAGAIN);
- return;
- }
-
- sock->ops = ops;
- sock->select_ep = NONE;
- sock->recv_data_size = 0;
-
- if (sock->ops && sock->ops->open)
- ret = sock->ops->open(sock, m);
-
- if (ret == OK) {
- debug_sock_print("new socket %ld", get_sock_num(sock));
- send_reply(m, get_sock_num(sock));
- } else {
- debug_sock_print("failed %d", ret);
- send_reply(m, ret);
- }
+ debug_sock_print("sock %ld status %d", get_sock_num(sock), status);
+ sock_reply_type(sock, DEV_REVIVE, status);
}
-static void do_status(message * m)
+struct socket * get_unused_sock(void)
{
int i;
- debug_sock_print("called");
-
- notified = 0;
-
- for (i = 0; i < MAX_SOCKETS; i++) {
- struct socket * sock = &socket[i];
- if (!sock->ops) {
- continue;
- }
- if (sock->flags & (SOCK_FLG_OP_REVIVING)) {
- /*
- * We send the reply and we are done with this request
- */
- debug_sock_print("status %d ep %d sent sock %ld type %d",
- sock->mess.REP_STATUS,
- sock->mess.REP_ENDPT,
- get_sock_num(sock),
- sock->mess.m_type);
- send(m->m_source, &sock->mess);
- /*
- * Remove only the reviving flag, i.e. the status has
- * been consumed. SOCK_FLG_OP_PENDING may stay set. For
- * instance in case of a TCP write, the application is
- * already notified while the process of sending is
- * still going on
- */
- sock->flags &= ~SOCK_FLG_OP_REVIVING;
- return;
- }
-
- /*
- * We check select AFTER possible reviving an operation,
- * otherwise the select will fail as the socket is still
- * blocking
- */
- if (sock_select_check_set(sock)) {
- if (sock->ops && sock->ops->select_reply) {
- message msg;
- msg.m_type = DEV_IO_READY;
- msg.DEV_MINOR = get_sock_num(sock);
- msg.DEV_SEL_OPS = 0;
- sock->ops->select_reply(sock, &msg);
- if (msg.DEV_SEL_OPS) {
- int result;
-
- debug_sock_print("socket num %d select "
- "result 0x%x sent",
- msg.DEV_MINOR,
- msg.DEV_SEL_OPS);
- result = send(sock->select_ep, &msg);
- if (result != OK)
- panic("LWIP : unable to send "
- "(err %d)", result);
- sock_clear_select(sock);
- sock->select_ep = NONE;
- return;
- }
- }
+ for (i = SOCK_TYPES + MAX_DEVS; i < MAX_SOCKETS; i++) {
+ if (socket[i].ops == NULL) {
+ /* clear it all */
+ memset(&socket[i], 0, sizeof(struct socket));
+ return &socket[i];
}
}
- debug_sock_print("no status");
- m->m_type = DEV_NO_STATUS;
- send(m->m_source, m);
+ return NULL;
}
static void socket_request_socket(struct socket * sock, message * m)
{
+ int blocking = m->FLAGS & FLG_OP_NONBLOCK ? 0 : 1;
+
switch (m->m_type) {
case DEV_READ_S:
if (sock && sock->ops && sock->ops->read)
- sock->ops->read(sock, m);
+ sock->ops->read(sock, m, blocking);
else
send_reply(m, EINVAL);
return;
case DEV_WRITE_S:
if (sock && sock->ops && sock->ops->write)
- sock->ops->write(sock, m);
+ sock->ops->write(sock, m, blocking);
else
send_reply(m, EINVAL);
return;
case DEV_IOCTL_S:
if (sock && sock->ops && sock->ops->ioctl)
- sock->ops->ioctl(sock, m);
+ sock->ops->ioctl(sock, m, blocking);
else
send_reply(m, EINVAL);
return;
default:
- panic("LWIP : cannot happen!");
+ netsock_panic("cannot happen!");
}
}
{
struct socket * sock;
+ debug_sock_print("request %d", m->m_type);
switch (m->m_type) {
case DEV_OPEN:
socket_open(m);
sock->mess = *m;
sock->ops->close(sock, m);
} else
- send_reply(m, EINVAL);
+ send_reply_close(m, EINVAL);
return;
case DEV_READ_S:
case DEV_WRITE_S:
* If an operation is pending (blocking operation) or writing is
* still going and we want to read, suspend the new operation
*/
- if ((sock->flags & (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_REVIVING)) |
+ if ((sock->flags & SOCK_FLG_OP_PENDING) ||
(m->m_type == DEV_READ_S &&
sock->flags & SOCK_FLG_OP_WRITING)) {
char * o = "\0";
o = "WRITE";
else
o = "non R/W op";
- debug_sock_print("socket %ld is busy by %s\n",
- get_sock_num(sock), o);
- if (mq_enqueue(m) == 0) {
- send_reply(m, SUSPEND);
- } else {
+ debug_sock_print("socket %ld is busy by %s flgs 0x%x\n",
+ get_sock_num(sock), o, sock->flags);
+ if (mq_enqueue(m) != 0) {
debug_sock_print("Enqueuing suspended "
"call failed");
send_reply(m, ENOMEM);
return;
case CANCEL:
sock = get_sock(m->DEVICE);
+ printf("socket num %ld\n", get_sock_num(sock));
debug_sock_print("socket num %ld", get_sock_num(sock));
/* Cancel the last operation in the queue */
if (mq_cancel(m)) {
sock->flags &= ~SOCK_FLG_OP_PENDING;
send_reply(m, EINTR);
return;
- /*
- * .. or return the status of the operation which was finished
- * before canceled
- */
- } else if (sock->flags & SOCK_FLG_OP_REVIVING) {
- sock->flags &= ~SOCK_FLG_OP_REVIVING;
- send_reply(m, sock->mess.REP_STATUS);
} else
- panic("LWIP : no operation to cancel");
+ netsock_panic("no operation to cancel");
return;
case DEV_SELECT:
- /*
+ /*
* Select is always executed immediately and is never suspended.
* Although, it sets actions which must be monitored
*/
sock = get_sock(m->DEVICE);
assert(sock->select_ep == NONE || sock->select_ep == m->m_source);
-
+
if (sock && sock->ops && sock->ops->select) {
+ sock->select_ep = m->m_source;
sock->ops->select(sock, m);
- if (sock_select_set(sock))
- sock->select_ep = m->m_source;
+ if (!sock_select_set(sock))
+ sock->select_ep = NONE;
} else
send_reply(m, EINVAL);
return;
- case DEV_STATUS:
- do_status(m);
- return;
default:
- printf("LWIP : unknown message from VFS, type %d\n",
+ netsock_error("unknown message from VFS, type %d\n",
m->m_type);
}
send_reply(m, EGENERIC);
while(mq) {
struct mq * next = mq->next;
-
+
sock = get_sock(mq->m.DEVICE);
- if (!(sock->flags &
- (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_REVIVING)) &&
+ if (!(sock->flags & SOCK_FLG_OP_PENDING) &&
!(mq->m.m_type == DEV_READ_S &&
- sock->flags & SOCK_FLG_OP_WRITING)) {
- sock->flags = SOCK_FLG_OP_SUSPENDED;
+ sock->flags & SOCK_FLG_OP_WRITING)) {
debug_sock_print("resuming op on sock %ld\n",
get_sock_num(sock));
sock->mess = mq->m;
{
int retsel = 0, sel;
- debug_print("socket num %ld 0x%x", get_sock_num(sock), m->USER_ENDPT);
+ debug_sock_print("socket num %ld 0x%x", get_sock_num(sock), m->USER_ENDPT);
sel = m->USER_ENDPT;
sock->flags |= SOCK_FLG_SEL_WRITE;
/* FIXME we do not monitor error */
}
- send_reply(m, 0);
+ sock_reply_select(sock, 0);
return;
}
retsel |= SEL_WR;
/* FIXME SEL_ERR is ignored, we do not generate exceptions */
- send_reply(m, retsel);
+ sock_reply_select(sock, retsel);
}
void generic_op_select_reply(struct socket * sock, __unused message * m)
{
assert(sock->select_ep != NONE);
- debug_print("socket num %ld", get_sock_num(sock));
+ debug_sock_print("socket num %ld", get_sock_num(sock));
/* unused for generic packet socket, see generic_op_select() */
assert((sock->flags & (SOCK_FLG_SEL_WRITE | SOCK_FLG_SEL_ERROR)) == 0);
- if (sock->flags & (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_REVIVING)) {
- debug_print("WARNING socket still blocking!");
+ if (sock->flags & SOCK_FLG_OP_PENDING) {
+ debug_sock_print("WARNING socket still blocking!");
return;
}
if (sock->flags & SOCK_FLG_SEL_READ && sock->recv_head)
m->DEV_SEL_OPS |= SEL_RD;
-
- if (m->DEV_SEL_OPS)
+
+ if (m->DEV_SEL_OPS)
sock->flags &= ~(SOCK_FLG_SEL_WRITE | SOCK_FLG_SEL_READ |
SOCK_FLG_SEL_ERROR);
}
#include <lwip/tcp_impl.h>
#include <lwip/ip_addr.h>
-#include "socket.h"
+#include <minix/netsock.h>
#include "proto.h"
#define TCP_BUF_SIZE (32 << 10)
}
if (sock->flags & SOCK_FLG_OP_PENDING) {
- sock_revive(sock, perr);
+ sock_reply(sock, perr);
sock->flags &= ~SOCK_FLG_OP_PENDING;
} else if (sock_select_set(sock))
sock_select_notify(sock);
}
debug_tcp_print("freed TX data");
- sock_reply(sock, OK);
+ sock_reply_close(sock, OK);
debug_tcp_print("socket unused");
-
+
/* mark it as unused */
sock->ops = NULL;
}
return EFAULT;
}
-static void tcp_op_read(struct socket * sock, message * m)
+static void tcp_op_read(struct socket * sock, message * m, int blk)
{
debug_tcp_print("socket num %ld", get_sock_num(sock));
sock_reply(sock, 0);
return;
}
+ if (!blk) {
+ debug_tcp_print("reading would block -> EAGAIN");
+ sock_reply(sock, EAGAIN);
+ return;
+ }
/* operation is being processed */
debug_tcp_print("no data to read, suspending");
- sock_reply(sock, SUSPEND);
sock->flags |= SOCK_FLG_OP_PENDING | SOCK_FLG_OP_READING;
}
}
return wc->head;
}
-static void tcp_op_write(struct socket * sock, message * m)
+static void tcp_op_write(struct socket * sock, message * m, __unused int blk)
{
int ret;
struct wbuf * wbuf;
/* wake up the reader and report EOF */
if (sock->flags & SOCK_FLG_OP_PENDING &&
- sock->flags & SOCK_FLG_OP_READING &&
- !(sock->flags & SOCK_FLG_OP_REVIVING)) {
- sock_revive(sock, 0);
+ sock->flags & SOCK_FLG_OP_READING) {
+ sock_reply(sock, 0);
sock->flags &= ~(SOCK_FLG_OP_PENDING |
SOCK_FLG_OP_READING);
}
if (sock->flags & SOCK_FLG_OP_READING) {
ret = read_from_tcp(sock, &sock->mess);
debug_tcp_print("read op finished");
- sock_revive(sock, ret);
+ sock_reply(sock, ret);
sock->flags &= ~(SOCK_FLG_OP_PENDING |
SOCK_FLG_OP_READING);
}
tcp_sent(tpcb, tcp_sent_callback);
tcp_recv(tpcb, tcp_recv_callback);
- sock_revive(sock, OK);
+ sock_reply(sock, OK);
sock->flags &= ~(SOCK_FLG_OP_PENDING | SOCK_FLG_OP_CONNECTING);
/* revive does the sock_select_notify() for us */
* Connecting is going to send some packets. Unless an immediate error
* occurs this operation is going to block
*/
- sock_reply(sock, SUSPEND);
sock->flags |= SOCK_FLG_OP_PENDING | SOCK_FLG_OP_CONNECTING;
/* try to connect now */
int ret;
ret = tcp_do_accept(sock, &sock->mess, newpcb);
- sock_revive(sock, ret);
+ sock_reply(sock, ret);
sock->flags &= ~SOCK_FLG_OP_PENDING;
if (ret == OK) {
return ERR_OK;
debug_tcp_print("no ready connection, suspending\n");
- sock_reply(sock, SUSPEND);
sock->flags |= SOCK_FLG_OP_PENDING;
}
sock_reply(sock, OK);
}
-static void tcp_op_ioctl(struct socket * sock, message * m)
+static void tcp_op_ioctl(struct socket * sock, message * m, __unused int blk)
{
if (!sock->pcb) {
sock_reply(sock, ENOTCONN);
if (sel & SEL_ERR)
sock->flags |= SOCK_FLG_SEL_ERROR;
}
- send_reply(m, 0);
+ sock_reply_select(sock, 0);
return;
}
if (sel & SEL_ERR && sel & SEL_NOTIFY)
sock->flags |= SOCK_FLG_SEL_ERROR;
- send_reply(m, retsel);
+ sock_reply_select(sock, retsel);
}
static void tcp_op_select_reply(struct socket * sock, message * m)
debug_tcp_print("socket num %ld", get_sock_num(sock));
- if (sock->flags & (SOCK_FLG_OP_PENDING | SOCK_FLG_OP_REVIVING)) {
+ if (sock->flags & SOCK_FLG_OP_PENDING) {
debug_tcp_print("WARNING socket still blocking!");
return;
}