/[packages]/cauldron/apcupsd/current/SOURCES/apcupsd-3.14-13-invalid-socket.patch
ViewVC logotype

Contents of /cauldron/apcupsd/current/SOURCES/apcupsd-3.14-13-invalid-socket.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 815016 - (show annotations) (download)
Mon Feb 16 01:14:15 2015 UTC (5 years, 5 months ago) by luigiwalser
File size: 2922 byte(s)
add upstream patch to fix NIS clients trying to run with no network connection
1 Index: src/apcaccess.c
2 ===================================================================
3 --- src/apcaccess.c (revision 2326)
4 +++ src/apcaccess.c (working copy)
5 @@ -49,7 +49,7 @@
6 char recvline[MAXSTRING + 1];
7 char *line;
8
9 - if ((sockfd = net_open(host, NULL, port)) == INVALID_SOCKET) {
10 + if ((sockfd = net_open(host, NULL, port)) < 0) {
11 fprintf(stderr, "Error contacting apcupsd @ %s:%d: %s\n",
12 host, port, strerror(-sockfd));
13 return 1;
14 Index: src/cgi/upsfetch.c
15 ===================================================================
16 --- src/cgi/upsfetch.c (revision 2326)
17 +++ src/cgi/upsfetch.c (working copy)
18 @@ -114,7 +114,7 @@
19 *p++ = '\0';
20 nis_port = atoi(p);
21 }
22 - if ((sockfd = net_open(lhost, NULL, nis_port)) == INVALID_SOCKET) {
23 + if ((sockfd = net_open(lhost, NULL, nis_port)) < 0) {
24 (void) snprintf(errmsg, sizeof (errmsg),
25 "upsfetch: tcp_open failed for %s port %d", lhost, nis_port);
26 return 0;
27 @@ -153,7 +153,7 @@
28 *p++ = '\0';
29 nis_port = atoi(p);
30 }
31 - if ((sockfd = net_open(lhost, NULL, nis_port)) == INVALID_SOCKET) {
32 + if ((sockfd = net_open(lhost, NULL, nis_port)) < 0) {
33 snprintf(errmsg, sizeof(errmsg),
34 "upsfetch: tcp_open failed for %s port %d", lhost, nis_port);
35 fputs(errmsg, stdout);
36 Index: src/drivers/net/net.c
37 ===================================================================
38 --- src/drivers/net/net.c (revision 2326)
39 +++ src/drivers/net/net.c (working copy)
40 @@ -202,8 +202,8 @@
41 _statlen = 0;
42
43 Dmsg(20, "Opening connection to %s:%d\n", _hostname, _port);
44 - if ((_sockfd = net_open(_hostname, NULL, _port)) == INVALID_SOCKET) {
45 - Dmsg(90, "Exit poll_ups 0 comm lost\n");
46 + if ((_sockfd = net_open(_hostname, NULL, _port)) < 0) {
47 + Dmsg(90, "Exit poll_ups 0 comm lost: %s\n", strerror(-_sockfd));
48 if (!_ups->is_commlost()) {
49 _ups->set_commlost();
50 }
51 @@ -210,9 +210,9 @@
52 return false;
53 }
54
55 - if (net_send(_sockfd, "status", 6) != 6) {
56 + if ((n = net_send(_sockfd, "status", 6)) != 6) {
57 net_close(_sockfd);
58 - Dmsg(90, "Exit poll_ups 0 no status flag\n");
59 + Dmsg(90, "Exit poll_ups 0 net_send fails: %s\n", strerror(-n));
60 _ups->set_commlost();
61 return false;
62 }
63 @@ -227,7 +227,7 @@
64
65 if (n < 0) {
66 stat = 0;
67 - Dmsg(90, "Exit poll_ups 0 bad stat net_recv\n");
68 + Dmsg(90, "Exit poll_ups 0 bad stat net_recv: %s\n", strerror(-n));
69 _ups->set_commlost();
70 } else {
71 _ups->clear_commlost();
72 Index: src/lib/statmgr.cpp
73 ===================================================================
74 --- src/lib/statmgr.cpp (revision 2326)
75 +++ src/lib/statmgr.cpp (working copy)
76 @@ -199,6 +199,8 @@
77 close();
78
79 m_socket = net_open(m_host, NULL, m_port);
80 + if (m_socket < 0)
81 + m_socket = INVALID_SOCKET;
82 return m_socket != INVALID_SOCKET;
83 }
84

  ViewVC Help
Powered by ViewVC 1.1.28