Merge remote-tracking branch 'aredlich/master'
Conflicts: lib/init.c lib/socket.c
This commit is contained in:
17
lib/init.c
17
lib/init.c
@@ -105,7 +105,7 @@ iscsi_create_context(const char *initiator_name)
|
||||
if (getenv("LIBISCSI_DEBUG") != NULL) {
|
||||
iscsi_set_debug(iscsi,atoi(getenv("LIBISCSI_DEBUG")));
|
||||
}
|
||||
|
||||
|
||||
if (getenv("LIBISCSI_TCP_USER_TIMEOUT") != NULL) {
|
||||
iscsi_set_tcp_user_timeout(iscsi,atoi(getenv("LIBISCSI_TCP_USER_TIMEOUT")));
|
||||
}
|
||||
@@ -236,7 +236,7 @@ iscsi_destroy_context(struct iscsi_context *iscsi)
|
||||
if (iscsi->is_loggedin) {
|
||||
pdu->callback(iscsi, SCSI_STATUS_CANCELLED, NULL,
|
||||
pdu->private_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
iscsi_free_pdu(iscsi, pdu);
|
||||
}
|
||||
@@ -284,7 +284,7 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...)
|
||||
strncpy(errstr,"could not format error string!",MAX_STRING_SIZE);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
|
||||
strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE);
|
||||
DPRINTF(iscsi,1,"%s",iscsi->error_string);
|
||||
}
|
||||
@@ -342,10 +342,10 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
char *portal;
|
||||
char *user = NULL;
|
||||
char *passwd = NULL;
|
||||
char *target;
|
||||
char *target = NULL;
|
||||
char *lun;
|
||||
char *tmp;
|
||||
int l;
|
||||
int l = 0;
|
||||
|
||||
if (strncmp(url, "iscsi://", 8)) {
|
||||
if (full) {
|
||||
@@ -429,12 +429,13 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
iscsi_url = iscsi_malloc(iscsi, sizeof(struct iscsi_url));
|
||||
else
|
||||
iscsi_url = malloc(sizeof(struct iscsi_url));
|
||||
|
||||
if (iscsi_url == NULL) {
|
||||
iscsi_set_error(iscsi, "Out-of-memory: Failed to allocate iscsi_url structure");
|
||||
return NULL;
|
||||
}
|
||||
memset(iscsi_url, 0, sizeof(struct iscsi_url));
|
||||
iscsi_url->iscsi= iscsi;
|
||||
iscsi_url->iscsi= iscsi;
|
||||
|
||||
strncpy(iscsi_url->portal,portal,MAX_STRING_SIZE);
|
||||
|
||||
@@ -442,12 +443,12 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
|
||||
strncpy(iscsi_url->user,user,MAX_STRING_SIZE);
|
||||
strncpy(iscsi_url->passwd,passwd,MAX_STRING_SIZE);
|
||||
}
|
||||
|
||||
|
||||
if (full) {
|
||||
strncpy(iscsi_url->target,target,MAX_STRING_SIZE);
|
||||
iscsi_url->lun = l;
|
||||
}
|
||||
|
||||
|
||||
return iscsi_url;
|
||||
}
|
||||
|
||||
|
||||
35
lib/socket.c
35
lib/socket.c
@@ -61,7 +61,7 @@ static void set_nonblocking(int fd)
|
||||
int set_tcp_sockopt(int sockfd, int optname, int value)
|
||||
{
|
||||
int level;
|
||||
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__sun)
|
||||
struct protoent *buf;
|
||||
|
||||
@@ -71,8 +71,8 @@ int set_tcp_sockopt(int sockfd, int optname, int value)
|
||||
return -1;
|
||||
#else
|
||||
level = SOL_TCP;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return setsockopt(sockfd, level, optname, &value, sizeof(value));
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
"Missing ']' in IPv6 address", portal);
|
||||
return -1;
|
||||
}
|
||||
*str = 0;
|
||||
*str = 0;
|
||||
}
|
||||
|
||||
/* is it a hostname ? */
|
||||
@@ -205,9 +205,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
iscsi->connect_data = private_data;
|
||||
|
||||
set_nonblocking(iscsi->fd);
|
||||
|
||||
|
||||
iscsi_set_tcp_keepalive(iscsi, iscsi->tcp_keepidle, iscsi->tcp_keepcnt, iscsi->tcp_keepintvl);
|
||||
|
||||
|
||||
if (iscsi->tcp_user_timeout > 0) {
|
||||
set_tcp_user_timeout(iscsi);
|
||||
}
|
||||
@@ -227,9 +227,9 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
}
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
|
||||
strncpy(iscsi->connected_portal,portal,MAX_STRING_SIZE);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ iscsi_disconnect(struct iscsi_context *iscsi)
|
||||
}
|
||||
|
||||
close(iscsi->fd);
|
||||
|
||||
|
||||
if (iscsi->connected_portal[0])
|
||||
DPRINTF(iscsi,2,"disconnected from portal %s",iscsi->connected_portal);
|
||||
|
||||
@@ -408,7 +408,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
|
||||
/* stop sending. maxcmdsn is reached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
total = iscsi->outqueue->outdata.size;
|
||||
total = (total + 3) & 0xfffffffc;
|
||||
|
||||
@@ -441,7 +441,7 @@ iscsi_write_to_socket(struct iscsi_context *iscsi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int
|
||||
static inline int
|
||||
iscsi_service_reconnect_if_loggedin(struct iscsi_context *iscsi)
|
||||
{
|
||||
if (iscsi->is_loggedin) {
|
||||
@@ -505,7 +505,7 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
|
||||
NULL, iscsi->connect_data);
|
||||
iscsi->socket_status_cb = NULL;
|
||||
}
|
||||
|
||||
|
||||
return iscsi_service_reconnect_if_loggedin(iscsi);
|
||||
}
|
||||
|
||||
@@ -586,31 +586,31 @@ iscsi_free_iscsi_inqueue(struct iscsi_context *iscsi, struct iscsi_in_pdu *inque
|
||||
void iscsi_set_tcp_syncnt(struct iscsi_context *iscsi, int value)
|
||||
{
|
||||
iscsi->tcp_syncnt=value;
|
||||
DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value);
|
||||
DPRINTF(iscsi,2,"TCP_SYNCNT will be set to %d on next socket creation",value);
|
||||
}
|
||||
|
||||
void iscsi_set_tcp_user_timeout(struct iscsi_context *iscsi, int value)
|
||||
{
|
||||
iscsi->tcp_user_timeout=value;
|
||||
DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value);
|
||||
DPRINTF(iscsi,2,"TCP_USER_TIMEOUT will be set to %dms on next socket creation",value);
|
||||
}
|
||||
|
||||
void iscsi_set_tcp_keepidle(struct iscsi_context *iscsi, int value)
|
||||
{
|
||||
iscsi->tcp_keepidle=value;
|
||||
DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value);
|
||||
DPRINTF(iscsi,2,"TCP_KEEPIDLE will be set to %d on next socket creation",value);
|
||||
}
|
||||
|
||||
void iscsi_set_tcp_keepcnt(struct iscsi_context *iscsi, int value)
|
||||
{
|
||||
iscsi->tcp_keepcnt=value;
|
||||
DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value);
|
||||
DPRINTF(iscsi,2,"TCP_KEEPCNT will be set to %d on next socket creation",value);
|
||||
}
|
||||
|
||||
void iscsi_set_tcp_keepintvl(struct iscsi_context *iscsi, int value)
|
||||
{
|
||||
iscsi->tcp_keepintvl=value;
|
||||
DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value);
|
||||
DPRINTF(iscsi,2,"TCP_KEEPINTVL will be set to %d on next socket creation",value);
|
||||
}
|
||||
|
||||
int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval)
|
||||
@@ -647,4 +647,3 @@ int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, in
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user