Changeset 14548
- Timestamp:
- Jul 1, 2015, 12:54:41 AM (8 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fdlimit.c
r14479 r14548 519 519 if ((s = socket (domain, type, 0)) == TR_BAD_SOCKET) 520 520 if (sockerrno != EAFNOSUPPORT) 521 tr_logAddError (_("Couldn't create socket: %s"), tr_strerror (sockerrno)); 521 { 522 char err_buf[512]; 523 tr_logAddError (_("Couldn't create socket: %s"), 524 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 525 } 522 526 523 527 if (s != TR_BAD_SOCKET) -
trunk/libtransmission/log.c
r14476 r14548 230 230 231 231 OutputDebugStringA (buf); 232 OutputDebugStringA (TR_NATIVE_EOL_STR); 232 233 233 234 if (*buf) -
trunk/libtransmission/net.c
r14527 r14548 77 77 #ifdef _WIN32 78 78 FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, buflen, NULL); 79 while (len > 0 && buf[len - 1] >= '\0' && buf[len - 1] <= ' ') 80 buf[--len] = '\0'; 79 81 #else 80 82 tr_strlcpy (buf, tr_strerror (err), buflen); … … 149 151 int tos) 150 152 { 151 #ifdef IP_TOS 152 if (setsockopt (s, IPPROTO_IP, IP_TOS, (const void *) &tos, sizeof (tos)) != -1) 153 return; 153 #if defined (IP_TOS) && !defined (_WIN32) 154 if (setsockopt (s, IPPROTO_IP, IP_TOS, (const void *) &tos, sizeof (tos)) == -1) 155 { 156 char err_buf[512]; 157 tr_logAddNamedInfo ("Net", "Can't set TOS '%d': %s", tos, 158 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 159 } 154 160 #else 155 161 (void) s; 156 errno = ENOSYS; 157 #endif 158 159 tr_logAddNamedInfo ("Net", "Can't set TOS '%d': %s", tos, tr_strerror (errno)); 162 (void) tos; 163 #endif 160 164 } 161 165 … … 166 170 #ifdef TCP_CONGESTION 167 171 if (setsockopt (s, IPPROTO_TCP, TCP_CONGESTION, 168 (const void *) algorithm, strlen (algorithm) + 1) != -1) 169 return; 170 172 (const void *) algorithm, strlen (algorithm) + 1) == -1) 173 { 174 char err_buf[512]; 175 tr_logAddNamedInfo ("Net", "Can't set congestion control algorithm '%s': %s", 176 algorithm, tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 177 } 171 178 #else 172 179 (void) s; 173 errno = ENOSYS; 174 #endif 175 176 tr_logAddNamedInfo ("Net", "Can't set congestion control algorithm '%s': %s", 177 algorithm, tr_strerror (errno)); 180 (void) algorithm; 181 #endif 178 182 } 179 183 … … 247 251 socklen_t sourcelen; 248 252 struct sockaddr_storage source_sock; 253 char err_buf[512]; 249 254 250 255 assert (tr_address_is_valid (addr)); … … 261 266 int n = 8192; 262 267 if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, (const void *) &n, sizeof (n))) 263 tr_logAddInfo ("Unable to set SO_RCVBUF on socket %"TR_PRI_SOCK": %s", s, tr_strerror (sockerrno)); 268 tr_logAddInfo ("Unable to set SO_RCVBUF on socket %"TR_PRI_SOCK": %s", s, 269 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 264 270 } 265 271 … … 278 284 { 279 285 tr_logAddError (_("Couldn't set source address %s on %"TR_PRI_SOCK": %s"), 280 tr_address_to_string (source_addr), s, tr_strerror (errno)); 286 tr_address_to_string (source_addr), s, 287 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 281 288 tr_netClose (session, s); 282 289 return TR_BAD_SOCKET; /* -errno */ … … 292 299 int tmperrno; 293 300 tmperrno = sockerrno; 294 if ((tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH) 295 || addr->type == TR_AF_INET)301 if ((tmperrno != ENETUNREACH && tmperrno != EHOSTUNREACH) || addr->type == TR_AF_INET) 302 { 296 303 tr_logAddError (_("Couldn't connect socket %"TR_PRI_SOCK" to %s, port %d (errno %d - %s)"), 297 s, tr_address_to_string (addr), (int)ntohs (port), tmperrno, 298 tr_strerror (tmperrno)); 304 s, tr_address_to_string (addr), (int)ntohs (port), tmperrno, 305 tr_net_strerror (err_buf, sizeof (err_buf), tmperrno)); 306 } 299 307 tr_netClose (session, s); 300 308 s = TR_BAD_SOCKET; /* -tmperrno */ … … 372 380 const char * fmt; 373 381 const char * hint; 382 char err_buf[512]; 374 383 375 384 if (err == EADDRINUSE) … … 383 392 fmt = _("Couldn't bind port %d on %s: %s (%s)"); 384 393 385 tr_logAddError (fmt, port, tr_address_to_string (addr), tr_strerror (err), hint); 394 tr_logAddError (fmt, port, tr_address_to_string (addr), 395 tr_net_strerror (err_buf, sizeof (err_buf), err), hint); 386 396 } 387 397 tr_netCloseSocket (fd); -
trunk/libtransmission/peer-io.c
r14545 r14548 1256 1256 { 1257 1257 int e; 1258 char err_buf[512]; 1258 1259 1259 1260 EVUTIL_SET_SOCKET_ERROR (0); … … 1261 1262 e = EVUTIL_SOCKET_ERROR (); 1262 1263 1263 dbgmsg (io, "read %d from peer (%s)", res, (res==-1?tr_strerror (e):"")); 1264 dbgmsg (io, "read %d from peer (%s)", res, 1265 (res==-1?tr_net_strerror (err_buf, sizeof (err_buf), e):"")); 1264 1266 1265 1267 if (evbuffer_get_length (io->inbuf)) … … 1268 1270 if ((res <= 0) && (io->gotError) && (e != EAGAIN) && (e != EINTR) && (e != EINPROGRESS)) 1269 1271 { 1270 char errstr[512];1271 1272 short what = BEV_EVENT_READING | BEV_EVENT_ERROR; 1272 1273 if (res == 0) 1273 1274 what |= BEV_EVENT_EOF; 1274 1275 dbgmsg (io, "tr_peerIoTryRead got an error. res is %d, what is %hd, errno is %d (%s)", 1275 res, what, e, tr_net_strerror (err str, sizeof (errstr), e));1276 res, what, e, tr_net_strerror (err_buf, sizeof (err_buf), e)); 1276 1277 io->gotError (io, what, io->userData); 1277 1278 } -
trunk/libtransmission/tr-udp.c
r14479 r14548 57 57 int size, rbuf, sbuf, rc; 58 58 socklen_t rbuf_len = sizeof (rbuf), sbuf_len = sizeof (sbuf); 59 char err_buf[512]; 59 60 60 61 size = large ? RECV_BUFFER_SIZE : SMALL_BUFFER_SIZE; … … 62 63 if (rc < 0) 63 64 tr_logAddNamedError ("UDP", "Failed to set receive buffer: %s", 64 tr_strerror (errno));65 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 65 66 66 67 size = large ? SEND_BUFFER_SIZE : SMALL_BUFFER_SIZE; … … 68 69 if (rc < 0) 69 70 tr_logAddNamedError ("UDP", "Failed to set send buffer: %s", 70 tr_strerror (errno));71 tr_net_strerror (err_buf, sizeof (err_buf), sockerrno)); 71 72 72 73 if (large) {
Note: See TracChangeset
for help on using the changeset viewer.