Kuro wrote:
> I added LOG_INFO code to utils.c and I also put back sleep(5) in
> slimproto.c. Here is what I see when server IP is changed:
>
> [00:54:16.480556] send_packet:92 failed writing to socket: Broken pipe
> [00:54:16.480872] slimproto_run:481 error reading from socket: closed
> [00:54:26.586495] slimproto:745 unable to connect to server 0
> [00:54:36.588881] slimproto:745 unable to connect to server 1
> [00:54:46.589753] slimproto:745 unable to connect to server 2
> [00:54:48.618917] connect_timeout:212 sock: 5 error: 113
> [00:54:48.619468] slimproto:754 connected
> [00:54:48.619903] sendHELO:114 mac: 00:25:31:02:c4:14
>
> So for some strange reason, select() returns 1 saying the socket is
> writable (the server at the old IP addr), and getsockopt() returns error
> code 113.
>
> According to errno.h, 113 is host unreachable.
>
> #define EHOSTUNREACH 113 /* No route to host */
>
> The strange thing is that if I removed sleep(5), select will never
> return 1 with the old sock connection.
Thanks - look there is a bug here - try the attached:
Code:
--------------------
--- a/slimproto.c
+++ b/slimproto.c
@@ -739,13 +739,13 @@ void slimproto(log_level level, char *server, u8_t
mac[6], const char *name) {
set_nonblock(sock);
set_nosigpipe(sock);
- if (connect_timeout(sock, (struct sockaddr *) &serv_addr,
sizeof(serv_addr), 5) < 0) {
+ if (connect_timeout(sock, (struct sockaddr *) &serv_addr,
sizeof(serv_addr), 5) != 0) {
- LOG_INFO("unable to connect to server %u",
failed_connect++);
+ LOG_INFO("unable to connect to server %u",
failed_connect);
sleep(5);
// rediscover server if it was not set at startup
- if (!server && failed_connect > 5) {
+ if (!server && ++failed_connect > 5) {
slimproto_ip = serv_addr.sin_addr.s_addr = discover_server();
}
--------------------
------------------------------------------------------------------------
Triode's Profile: http://forums.slimdevices.com/member.php?userid=17
View this thread: http://forums.slimdevices.com/showthread.php?t=97046
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix