Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| SHA1 Hash: | 0268e771ef8c10e7cb8a90aa0c743a9e4fd5c817 |
|---|---|
| Date: | 2012-07-05 21:25:26 |
| User: | drh |
| Comment: | Work toward getting Fossil to be able to sync over IPV6. This check-in compiles, but we do not yet have a server to test it on. |
Tags And Properties
- branch=ipv6 propagates to descendants
- sym-ipv6 propagates to descendants
- sym-trunk cancelled
Changes
Changes to src/http_socket.c
134 ** g.urlName Name of the server. Ex: www.fossil-scm.org 134 ** g.urlName Name of the server. Ex: www.fossil-scm.org 135 ** g.urlPort TCP/IP port to use. Ex: 80 135 ** g.urlPort TCP/IP port to use. Ex: 80 136 ** 136 ** 137 ** Return the number of errors. 137 ** Return the number of errors. 138 */ 138 */ 139 int socket_open(void){ 139 int socket_open(void){ 140 static struct sockaddr_in addr; /* The server address */ 140 static struct sockaddr_in addr; /* The server address */ 141 static int addrIsInit = 0; /* True once addr is initialized */ | 141 static int addrIsInit = 0; /* True when initialized once */ > 142 static struct addrinfo *p = 0; /* Succcessful open */ 142 143 143 socket_global_init(); 144 socket_global_init(); 144 if( !addrIsInit ){ 145 if( !addrIsInit ){ 145 addr.sin_family = AF_INET; < 146 addr.sin_port = htons(g.urlPort); | 146 struct addrinfo sHints; 147 *(int*)&addr.sin_addr = inet_addr(g.urlName); | 147 int rc; 148 if( -1 == *(int*)&addr.sin_addr ){ | 148 char zPort[30]; 149 #ifndef FOSSIL_STATIC_LINK < 150 struct hostent *pHost; < 151 pHost = gethostbyname(g.urlName); < 152 if( pHost!=0 ){ < 153 memcpy(&addr.sin_addr,pHost->h_addr_list[0],pHost->h_length); < 154 }else < 155 #endif < 156 { | 149 > 150 memset(&sHints, 0, sizeof(sHints)); > 151 sHints.ai_family = AF_UNSPEC; > 152 sHints.ai_socktype = SOCK_STREAM; > 153 sHints.ai_flags = 0; > 154 sHints.ai_protocol = 0; > 155 sqlite3_snprintf(sizeof(zPort), zPort, "%d", g.urlPort); > 156 rc = getaddrinfo(g.urlName, zPort, &sHints, &p); 157 socket_set_errmsg("can't resolve host name: %s", g.urlName); | 157 if( rc!=0 ){ 158 return 1; | 158 fossil_error("getaddrinfo: %s", gai_strerror(rc)); 159 } | 159 } 160 } < 161 addrIsInit = 1; 160 addrIsInit = 1; 162 | 161 } 163 /* Set the Global.zIpAddr variable to the server we are talking to. < 164 ** This is used to populate the ipaddr column of the rcvfrom table, < 165 ** if any files are received from the server. < 166 */ < 167 g.zIpAddr = mprintf("%s", inet_ntoa(addr.sin_addr)); < 168 } | 162 169 iSocket = socket(AF_INET,SOCK_STREAM,0); < > 163 while( p ){ > 164 char zHost[NI_MAXHOST]; > 165 iSocket = socket(p->ai_family, p->ai_socktype, p->ai_protocol); 170 if( iSocket<0 ){ | 166 if( iSocket<0 ){ 171 socket_set_errmsg("cannot create a socket"); < 172 return 1; < > 167 p = p->ai_next; > 168 continue; 173 } | 169 } 174 if( connect(iSocket,(struct sockaddr*)&addr,sizeof(addr))<0 ){ < 175 socket_set_errmsg("cannot connect to host %s:%d", g.urlName, g.urlPort); < > 170 if( connect(iSocket, p->ai_addr, p->ai_addrlen)<0 ){ > 171 p = p->ai_next; 176 socket_close(); | 172 socket_close(); > 173 continue; > 174 } > 175 p->ai_next = 0; > 176 if( getnameinfo(p->ai_addr, p->ai_addrlen, zHost, sizeof(zHost), > 177 0, 0, NI_NUMERICHOST)==0 ){ > 178 g.zIpAddr = mprintf("%s", zHost); > 179 }else{ > 180 fossil_fatal("cannot find numeric host IP address"); > 181 } > 182 } > 183 if( p==0 ){ > 184 socket_set_errmsg("cannot create a socket"); 177 return 1; 185 return 1; 178 } 186 } 179 #if !defined(_WIN32) 187 #if !defined(_WIN32) 180 signal(SIGPIPE, SIG_IGN); 188 signal(SIGPIPE, SIG_IGN); 181 #endif 189 #endif 182 return 0; 190 return 0; 183 } 191 }