"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "socket.c" between
rsync-3.2.1.tar.gz and rsync-3.2.2.tar.gz

About: rsync is a fast incremental file-copying tool for bringing remote (and local) files into sync.

socket.c  (rsync-3.2.1):socket.c  (rsync-3.2.2)
skipping to change at line 29 skipping to change at line 29
* with this program; if not, visit the http://fsf.org website. * with this program; if not, visit the http://fsf.org website.
*/ */
/* This file is now converted to use the new-style getaddrinfo() /* This file is now converted to use the new-style getaddrinfo()
* interface, which supports IPv6 but is also supported on recent * interface, which supports IPv6 but is also supported on recent
* IPv4-only machines. On systems that don't have that interface, we * IPv4-only machines. On systems that don't have that interface, we
* emulate it using the KAME implementation. */ * emulate it using the KAME implementation. */
#include "rsync.h" #include "rsync.h"
#include "itypes.h" #include "itypes.h"
#include "ifuncs.h"
#ifdef HAVE_NETINET_IN_SYSTM_H #ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h> #include <netinet/in_systm.h>
#endif #endif
#ifdef HAVE_NETINET_IP_H #ifdef HAVE_NETINET_IP_H
#include <netinet/ip.h> #include <netinet/ip.h>
#endif #endif
#include <netinet/tcp.h> #include <netinet/tcp.h>
extern char *bind_address; extern char *bind_address;
extern char *sockopts; extern char *sockopts;
skipping to change at line 250 skipping to change at line 251
hints.ai_socktype = type; hints.ai_socktype = type;
error = getaddrinfo(h, portbuf, &hints, &res0); error = getaddrinfo(h, portbuf, &hints, &res0);
if (error) { if (error) {
rprintf(FERROR, RSYNC_NAME ": getaddrinfo: %s %s: %s\n", rprintf(FERROR, RSYNC_NAME ": getaddrinfo: %s %s: %s\n",
h, portbuf, gai_strerror(error)); h, portbuf, gai_strerror(error));
return -1; return -1;
} }
for (res = res0, addr_cnt = 0; res; res = res->ai_next, addr_cnt++) {} for (res = res0, addr_cnt = 0; res; res = res->ai_next, addr_cnt++) {}
errnos = new_array0(int, addr_cnt); errnos = new_array0(int, addr_cnt);
if (!errnos)
out_of_memory("open_socket_out");
s = -1; s = -1;
/* Try to connect to all addresses for this machine until we get /* Try to connect to all addresses for this machine until we get
* through. It might e.g. be multi-homed, or have both IPv4 and IPv6 * through. It might e.g. be multi-homed, or have both IPv4 and IPv6
* addresses. We need to create a socket for each record, since the * addresses. We need to create a socket for each record, since the
* address record tells us what protocol to use to try to connect. */ * address record tells us what protocol to use to try to connect. */
for (res = res0, j = 0; res; res = res->ai_next, j++) { for (res = res0, j = 0; res; res = res->ai_next, j++) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol); s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s < 0) if (s < 0)
continue; continue;
skipping to change at line 355 skipping to change at line 354
for (f = prog; *f; f++) { for (f = prog; *f; f++) {
if (*f != '%') if (*f != '%')
continue; continue;
/* Compute more than enough room. */ /* Compute more than enough room. */
if (f[1] == '%') if (f[1] == '%')
f++; f++;
else else
len += hlen; len += hlen;
} }
f = prog; f = prog;
if (!(prog = new_array(char, len))) prog = new_array(char, len);
out_of_memory("open_socket_out_wrapped");
for (t = prog; *f; f++) { for (t = prog; *f; f++) {
if (*f == '%') { if (*f == '%') {
switch (*++f) { switch (*++f) {
case '%': case '%':
/* Just skips the extra '%'. */ /* Just skips the extra '%'. */
break; break;
case 'H': case 'H':
memcpy(t, host, hlen); memcpy(t, host, hlen);
t += hlen; t += hlen;
continue; continue;
skipping to change at line 423 skipping to change at line 421
rprintf(FERROR, RSYNC_NAME ": getaddrinfo: bind address %s: %s\n" , rprintf(FERROR, RSYNC_NAME ": getaddrinfo: bind address %s: %s\n" ,
bind_addr, gai_strerror(error)); bind_addr, gai_strerror(error));
return NULL; return NULL;
} }
/* Count max number of sockets we might open. */ /* Count max number of sockets we might open. */
for (maxs = 0, resp = all_ai; resp; resp = resp->ai_next, maxs++) {} for (maxs = 0, resp = all_ai; resp; resp = resp->ai_next, maxs++) {}
socks = new_array(int, maxs + 1); socks = new_array(int, maxs + 1);
errmsgs = new_array(char *, maxs); errmsgs = new_array(char *, maxs);
if (!socks || !errmsgs)
out_of_memory("open_socket_in");
/* We may not be able to create the socket, if for example the /* We may not be able to create the socket, if for example the
* machine knows about IPv6 in the C library, but not in the * machine knows about IPv6 in the C library, but not in the
* kernel. */ * kernel. */
for (resp = all_ai, i = ecnt = 0; resp; resp = resp->ai_next) { for (resp = all_ai, i = ecnt = 0; resp; resp = resp->ai_next) {
s = socket(resp->ai_family, resp->ai_socktype, s = socket(resp->ai_family, resp->ai_socktype,
resp->ai_protocol); resp->ai_protocol);
if (s == -1) { if (s == -1) {
int r = asprintf(&errmsgs[ecnt++], int r = asprintf(&errmsgs[ecnt++],
skipping to change at line 679 skipping to change at line 675
/* Set user socket options. */ /* Set user socket options. */
void set_socket_options(int fd, char *options) void set_socket_options(int fd, char *options)
{ {
char *tok; char *tok;
if (!options || !*options) if (!options || !*options)
return; return;
options = strdup(options); options = strdup(options);
if (!options)
out_of_memory("set_socket_options");
for (tok = strtok(options, " \t,"); tok; tok = strtok(NULL," \t,")) { for (tok = strtok(options, " \t,"); tok; tok = strtok(NULL," \t,")) {
int ret=0,i; int ret=0,i;
int value = 1; int value = 1;
char *p; char *p;
int got_value = 0; int got_value = 0;
if ((p = strchr(tok,'='))) { if ((p = strchr(tok,'='))) {
*p = 0; *p = 0;
value = atoi(p+1); value = atoi(p+1);
got_value = 1; got_value = 1;
 End of changes. 5 change blocks. 
9 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)