[PATCH 5/9] iscsid: Add start/stop transmit abstraction

In order to be able to abstract from socket and iser connection fd's
we need to have generic code that can handle both.

Signed-off-by: Yan Burman <yanb@mellanox.com>




git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5233 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2014-01-28 04:17:32 +00:00
parent 5357b4c37d
commit 39d0b2983a
2 changed files with 12 additions and 5 deletions
+10 -5
View File
@@ -170,6 +170,12 @@ static void create_listen_socket(struct pollfd *array)
exit(1);
}
static int transmit_sock(int fd, bool start)
{
int opt = start;
return setsockopt(fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt));
}
static void accept_connection(int listen)
{
union {
@@ -261,6 +267,7 @@ static void accept_connection(int listen)
}
incoming[i] = conn;
conn->transmit = transmit_sock;
conn_read_pdu(conn);
set_non_blocking(fd);
@@ -297,7 +304,7 @@ void isns_set_fd(int isns, int scn_listen, int scn)
static void event_conn(struct connection *conn, struct pollfd *pollfd)
{
int res, opt;
int res;
again:
switch (conn->iostate) {
@@ -368,8 +375,7 @@ again:
case IOSTATE_WRITE_AHS:
case IOSTATE_WRITE_DATA:
write_again:
opt = 1;
setsockopt(pollfd->fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt));
conn->transmit(pollfd->fd, true);
res = write(pollfd->fd, conn->buffer, conn->rwsize);
if (res < 0) {
if (errno != EINTR && errno != EAGAIN) {
@@ -409,8 +415,7 @@ again:
goto write_again;
}
case IOSTATE_WRITE_DATA:
opt = 0;
setsockopt(pollfd->fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt));
conn->transmit(pollfd->fd, false);
cmnd_finish(conn);
switch (conn->state) {
+2
View File
@@ -127,6 +127,8 @@ struct connection {
} auth;
struct __qelem clist;
int (*transmit)(int fd, bool start);
};
#define IOSTATE_FREE 0