diff options
author | Martin Willi <martin@strongswan.org> | 2009-09-29 08:53:58 +0200 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-04-07 13:55:15 +0200 |
commit | 5d6725904216debf70680da8492745c987a1189d (patch) | |
tree | ccf09325a5162f776ad360ff639f3488aa0054ee /src/charon | |
parent | 06308d9ede98fef049b68e4cb94abd3a6787b090 (diff) | |
download | strongswan-5d6725904216debf70680da8492745c987a1189d.tar.bz2 strongswan-5d6725904216debf70680da8492745c987a1189d.tar.xz |
Use a connected UDP socket
Diffstat (limited to 'src/charon')
-rw-r--r-- | src/charon/plugins/ha_sync/ha_sync_socket.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/charon/plugins/ha_sync/ha_sync_socket.c b/src/charon/plugins/ha_sync/ha_sync_socket.c index cbbe16711..b6b61d12c 100644 --- a/src/charon/plugins/ha_sync/ha_sync_socket.c +++ b/src/charon/plugins/ha_sync/ha_sync_socket.c @@ -124,19 +124,20 @@ static ha_sync_message_t *pull(private_ha_sync_socket_t *this) ssize_t len; pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - len = recvfrom(this->fd, buf, sizeof(buf), 0, - this->remote->get_sockaddr(this->remote), - this->remote->get_sockaddr_len(this->remote)); + len = recv(this->fd, buf, sizeof(buf), 0); pthread_setcancelstate(oldstate, NULL); if (len <= 0) { - if (errno != EINTR) + switch (errno) { - DBG1(DBG_CFG, "pulling HA sync message failed: %s", - strerror(errno)); - sleep(1); + case ECONNREFUSED: + case EINTR: + continue; + default: + DBG1(DBG_CFG, "pulling HA sync message failed: %s", + strerror(errno)); + sleep(1); } - continue; } message = ha_sync_message_parse(chunk_create(buf, len)); if (message) @@ -166,6 +167,15 @@ static bool open_socket(private_ha_sync_socket_t *this) this->fd = -1; return FALSE; } + if (connect(this->fd, this->remote->get_sockaddr(this->remote), + *this->remote->get_sockaddr_len(this->remote)) == -1) + { + DBG1(DBG_CFG, "connecting HA sync socket failed: %s", strerror(errno)); + close(this->fd); + this->fd = -1; + return FALSE; + } + return TRUE; } |