~hartmut-php/drizzle/codestyle

« back to all changes in this revision

Viewing changes to libdrizzle/client.c

  • Committer: Monty Taylor
  • Date: 2008-08-10 16:52:18 UTC
  • mfrom: (293 drizzle)
  • mto: (312.1.3 translations)
  • mto: This revision was merged to the branch mainline in revision 295.
  • Revision ID: monty@inaugust.com-20080810165218-jlekj1n46oyx9sih
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1270
1270
 
1271
1271
    memset(&hints, 0, sizeof(hints));
1272
1272
    hints.ai_socktype= SOCK_STREAM;
1273
 
    /* OSX 10.5 was failing unless defined only as support IPV4 */
1274
 
#ifdef TARGET_OS_OSX
1275
 
    hints.ai_family= AF_INET;
1276
 
#endif
1277
 
 
1278
1273
 
1279
1274
    snprintf(port_buf, NI_MAXSERV, "%d", port);
1280
1275
    gai_errno= getaddrinfo(host, port_buf, &hints, &res_lst);
1287
1282
      goto error;
1288
1283
    }
1289
1284
 
1290
 
    /* We only look at the first item (something to think about changing in the future) */
1291
 
    t_res= res_lst;
 
1285
    for (t_res= res_lst; t_res != NULL; t_res= t_res->ai_next)
1292
1286
    {
1293
1287
      int sock= socket(t_res->ai_family, t_res->ai_socktype,
1294
 
                             t_res->ai_protocol);
 
1288
                       t_res->ai_protocol);
1295
1289
      if (sock == SOCKET_ERROR)
1296
 
      {
1297
 
        set_drizzle_extended_error(drizzle, CR_IPSOCK_ERROR, unknown_sqlstate,
1298
 
                                 ER(CR_IPSOCK_ERROR), socket_errno);
1299
 
        freeaddrinfo(res_lst);
1300
 
        goto error;
1301
 
      }
 
1290
        continue;
1302
1291
 
1303
1292
      net->vio= vio_new(sock, VIO_TYPE_TCPIP, VIO_BUFFERED_READ);
1304
1293
      if (! net->vio )
1305
1294
      {
1306
 
        set_drizzle_error(drizzle, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
1307
 
        closesocket(sock);
1308
 
        freeaddrinfo(res_lst);
1309
 
        goto error;
 
1295
        close(sock);
 
1296
        continue;
1310
1297
      }
1311
1298
 
1312
1299
      if (connect_with_timeout(sock, t_res->ai_addr, t_res->ai_addrlen, drizzle->options.connect_timeout))
1313
1300
      {
1314
 
        set_drizzle_extended_error(drizzle, CR_CONN_HOST_ERROR, unknown_sqlstate,
1315
 
                                 ER(CR_CONN_HOST_ERROR), host, socket_errno);
1316
1301
        vio_delete(net->vio);
1317
1302
        net->vio= 0;
1318
 
        freeaddrinfo(res_lst);
1319
 
        goto error;
 
1303
        continue;
1320
1304
      }
 
1305
      break;
1321
1306
    }
1322
1307
 
1323
1308
    freeaddrinfo(res_lst);
1325
1310
 
1326
1311
  if (!net->vio)
1327
1312
  {
1328
 
    set_drizzle_error(drizzle, CR_CONN_UNKNOW_PROTOCOL, unknown_sqlstate);
 
1313
    set_drizzle_extended_error(drizzle, CR_CONN_HOST_ERROR, unknown_sqlstate,
 
1314
                               ER(CR_CONN_HOST_ERROR), host, socket_errno);
1329
1315
    goto error;
1330
1316
  }
1331
1317