Fossil

Check-in [ae3ef4d3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhance the "fossil sync" command to retry all of the returned values from getaddrinfo() until it finds one that actually works. That way, it will find the IPv4 version on machines that do not have an IPv6 gateway.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ae3ef4d3d9d786c79afb805ad9892cca82bde046
User & Date: drh 2015-01-24 22:13:38
Context
2015-01-25
21:21
Improved tracing capability for debugging purposes. check-in: af3d3b69 user: drh tags: trunk
09:54
Merge latest trunk check-in: befd44c7 user: baruch tags: svn-import
00:20
Enhance the MLINK table schema to record file changes from all parents. Requires a "fossil rebuild". Other schema cleanups at the same time. check-in: a241444d user: drh tags: mlink-improvements
2015-01-24
22:13
Enhance the "fossil sync" command to retry all of the returned values from getaddrinfo() until it finds one that actually works. That way, it will find the IPv4 version on machines that do not have an IPv6 gateway. check-in: ae3ef4d3 user: drh tags: trunk
21:46
Add the --ipv4 option to force the use of IPv4 on "fossil clone" and "fossil sync" and so forth. check-in: 317bd3cb user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/http_socket.c.

135
136
137
138
139
140
141

142
143
144
145
146
147
148
...
151
152
153
154
155
156
157







158
159
160
161
162
163
164
165
166
167
168
169

170
171

172
173
174
175
176
177
178
179
180
181
182
**    pUrlDAta->port       TCP/IP port to use.  Ex: 80
**
** Return the number of errors.
*/
int socket_open(UrlData *pUrlData){
  int rc = 0;
  struct addrinfo *ai = 0;

  struct addrinfo hints;
  char zPort[30];
  char zRemote[NI_MAXHOST];

  socket_global_init();
  memset(&hints, 0, sizeof(struct addrinfo));
  assert( iSocket<0 );
................................................................................
  hints.ai_protocol = IPPROTO_TCP;
  sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
  rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
  if( rc ){
    socket_set_errmsg("getaddrinfo() fails: %s", gai_strerror(rc));
    goto end_socket_open;
  }







  rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, zRemote, sizeof(zRemote),
                   0, 0, NI_NUMERICHOST);
  if( rc ){
    socket_set_errmsg("getnameinfo() failed: %s", gai_strerror(rc));
    goto end_socket_open;
  }
  g.zIpAddr = mprintf("%s", zRemote);
  iSocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  if( iSocket<0 ){
    socket_set_errmsg("cannot create a socket");
    rc = 1;
    goto end_socket_open;

  }
  if( connect(iSocket,ai->ai_addr,ai->ai_addrlen)<0 ){

    socket_set_errmsg("cannot connect to host %s:%d", pUrlData->name,
                      pUrlData->port);
    rc = 1;
    goto end_socket_open;
  }
#if !defined(_WIN32)
  signal(SIGPIPE, SIG_IGN);
#endif
end_socket_open:
  if( rc && iSocket>=0 ) socket_close();
  if( ai ) freeaddrinfo(ai);







>







 







>
>
>
>
>
>
>
|
|
|
|
|
|
|
<
<
<
<
<
>

<
>


<
<







135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
...
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172





173
174

175
176
177


178
179
180
181
182
183
184
**    pUrlDAta->port       TCP/IP port to use.  Ex: 80
**
** Return the number of errors.
*/
int socket_open(UrlData *pUrlData){
  int rc = 0;
  struct addrinfo *ai = 0;
  struct addrinfo *p;
  struct addrinfo hints;
  char zPort[30];
  char zRemote[NI_MAXHOST];

  socket_global_init();
  memset(&hints, 0, sizeof(struct addrinfo));
  assert( iSocket<0 );
................................................................................
  hints.ai_protocol = IPPROTO_TCP;
  sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
  rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
  if( rc ){
    socket_set_errmsg("getaddrinfo() fails: %s", gai_strerror(rc));
    goto end_socket_open;
  }
  for(p=ai; p; p=p->ai_next){
    iSocket = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
    if( iSocket<0 ) continue;
    if( connect(iSocket,p->ai_addr,p->ai_addrlen)<0 ){
      socket_close();
      continue;
    }
    rc = getnameinfo(p->ai_addr, p->ai_addrlen, zRemote, sizeof(zRemote),
                     0, 0, NI_NUMERICHOST);
    if( rc ){
      socket_set_errmsg("getnameinfo() failed: %s", gai_strerror(rc));
      goto end_socket_open;
    }
    g.zIpAddr = mprintf("%s", zRemote);





    break;
  }

  if( p==0 ){
    socket_set_errmsg("cannot connect to host %s:%d", pUrlData->name,
                      pUrlData->port);


  }
#if !defined(_WIN32)
  signal(SIGPIPE, SIG_IGN);
#endif
end_socket_open:
  if( rc && iSocket>=0 ) socket_close();
  if( ai ) freeaddrinfo(ai);