Fossil

Changes On Branch ipv6-sync
Login

Changes On Branch ipv6-sync

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

Changes In Branch ipv6-sync Excluding Merge-Ins

This is equivalent to a diff from 0cdec7d290 to 3842742871

2015-01-23
02:05
Use IPv6 for "fossil sync" when available. ... (check-in: 1dbd4d0d0b user: drh tags: trunk)
01:58
Use IPv6 when available for "fossil sync". ... (Closed-Leaf check-in: 3842742871 user: drh tags: ipv6-sync)
2015-01-22
23:45
Enhance the table sorting javascript to support initial reverse-order sorting. Add table sorting to the user log. ... (check-in: 0cdec7d290 user: drh tags: trunk)
22:52
Make table sorting (by clicking on column headers) stable. In other words, identical values in the column being sorted preserve their prior relative order. Patch suggested by Jacek Cała. ... (check-in: fe61f4958d user: drh tags: trunk)

Changes to src/http_socket.c.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
43
44
45
46
47
48
49

50
51
52
53
54
55
56







-








/*
** There can only be a single socket connection open at a time.
** State information about that socket is stored in the following
** local variables:
*/
static int socketIsInit = 0;    /* True after global initialization */
static int addrIsInit = 0;      /* True once addr is initialized */
#if defined(_WIN32)
static WSADATA socketInfo;      /* Windows socket initialize data */
#endif
static int iSocket = -1;        /* The socket on which we talk to the server */
static char *socketErrMsg = 0;  /* Text of most recent socket error */


104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
103
104
105
106
107
108
109

110
111
112
113
114
115
116







-







  if( socketIsInit ){
#if defined(_WIN32)
    WSACleanup();
#endif
    socket_clear_errmsg();
    socketIsInit = 0;
  }
  addrIsInit = 0;
}

/*
** Close the currently open socket.  If no socket is open, this routine
** is a no-op.
*/
void socket_close(void){
132
133
134
135
136
137
138


139



140
141
142
143
144
145






146
147
148
149
150
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

183
184
185
186
187
188
189
130
131
132
133
134
135
136
137
138

139
140
141
142
143




144
145
146
147
148
149






150
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
183
184
185
186
187







+
+
-
+
+
+


-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
-
-
+


-
+
+

-
+


+
-
+
-




+
+
+
-
+







**
**    pUrlDAta->name       Name of the server.  Ex: www.fossil-scm.org
**    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;
  static struct sockaddr_in addr;  /* The server address */
  struct addrinfo hints;
  char zPort[30];
  char zRemote[NI_MAXHOST];

  socket_global_init();
  if( !addrIsInit ){
    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(pUrlData->port);
  memset(&hints, 0, sizeof(struct addrinfo));
  assert( iSocket<0 );
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_protocol = IPPROTO_TCP;
  sqlite3_snprintf(sizeof(zPort),zPort,"%d", pUrlData->port);
    *(int*)&addr.sin_addr = inet_addr(pUrlData->name);
    if( -1 == *(int*)&addr.sin_addr ){
#ifndef FOSSIL_STATIC_LINK
      struct hostent *pHost;
      pHost = gethostbyname(pUrlData->name);
      if( pHost!=0 ){
  rc = getaddrinfo(pUrlData->name, zPort, &hints, &ai);
  if( rc ){
        memcpy(&addr.sin_addr,pHost->h_addr_list[0],pHost->h_length);
      }else
#endif
      {
        socket_set_errmsg("can't resolve host name: %s", pUrlData->name);
        return 1;
      }
    socket_set_errmsg("getaddrinfo() fails: %s", gai_strerror(rc));
    goto end_socket_open;
  }
    }
    addrIsInit = 1;

  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;
  }
    /* Set the Global.zIpAddr variable to the server we are talking to.
    ** This is used to populate the ipaddr column of the rcvfrom table,
    ** if any files are received from the server.
    */
    g.zIpAddr = mprintf("%s", inet_ntoa(addr.sin_addr));
  g.zIpAddr = mprintf("%s", zRemote);
  }
  iSocket = socket(AF_INET,SOCK_STREAM,0);
  iSocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  if( iSocket<0 ){
    socket_set_errmsg("cannot create a socket");
    return 1;
    rc = 1;
    goto end_socket_open;
  }
  if( connect(iSocket,(struct sockaddr*)&addr,sizeof(addr))<0 ){
  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;
    socket_close();
    goto end_socket_open;
    return 1;
  }
#if !defined(_WIN32)
  signal(SIGPIPE, SIG_IGN);
#endif
end_socket_open:
  if( rc && iSocket>=0 ) socket_close();
  if( ai ) freeaddrinfo(ai);
  return 0;
  return rc;
}

/*
** Send content out over the open socket connection.
*/
size_t socket_send(void *NotUsed, void *pContent, size_t N){
  size_t sent;
Changes to src/xfer.c.
1964
1965
1966
1967
1968
1969
1970
1971
1972


1973
1974
1975
1976
1977
1978
1979
1964
1965
1966
1967
1968
1969
1970


1971
1972
1973
1974
1975
1976
1977
1978
1979







-
-
+
+







     fossil_warning("*** time skew *** server is slow by %s",
                    db_timespan_name(-rSkew));
     g.clockSkewSeen = 1;
  }

  fossil_force_newline();
  fossil_print(
     "%s finished with %lld bytes sent, %lld bytes received\n",
     zOpType, nSent, nRcvd);
     "Total bytes sent: %lld  received: %lld  ip: %s\n",
      nSent, nRcvd, g.zIpAddr);
  transport_close(&g.url);
  transport_global_shutdown(&g.url);
  if( nErr && go==2 ){
    db_multi_exec("DROP TABLE onremote");
    manifest_crosslink_end(MC_PERMIT_HOOKS);
    content_enable_dephantomize(1);
    db_end_transaction(0);