~drizzle-trunk/libdrizzle/libdrizzle-redux

« back to all changes in this revision

Viewing changes to libdrizzle/conn.cc

  • Committer: Continuous Integration
  • Date: 2013-01-26 23:40:10 UTC
  • mfrom: (95.2.2 5.1-con-opts2)
  • Revision ID: ci@drizzle.org-20130126234010-779kn3i08xt1cvi6
Merge lp:~linuxjedi/libdrizzle/5.1-con-opts2 Build: jenkins-Libdrizzle-52

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
 
221
221
  __closesocket(con->fd);
222
222
 
223
 
  con->options = (drizzle_options_t)((int)con->options & (int)~DRIZZLE_CON_READY);
 
223
  con->state.ready= false;
224
224
  con->packet_number= 0;
225
225
  con->buffer_ptr= con->buffer;
226
226
  con->buffer_size= 0;
250
250
  }
251
251
 
252
252
  if (revents != 0)
253
 
    con->options = (drizzle_options_t)((int)con->options | (int)DRIZZLE_CON_IO_READY);
 
253
    con->state.io_ready= true;
254
254
 
255
255
  con->revents= revents;
256
256
 
300
300
  return con->sqlstate;
301
301
}
302
302
 
303
 
drizzle_options_t drizzle_options(const drizzle_st *con)
304
 
{
305
 
  if (con == NULL)
306
 
  {
307
 
    return DRIZZLE_CON_NONE;
308
 
  }
309
 
 
310
 
  return drizzle_options_t(con->options);
311
 
}
312
 
 
313
 
void drizzle_set_options(drizzle_st *con,
314
 
                             drizzle_options_t options)
315
 
{
316
 
  if (con == NULL)
317
 
  {
318
 
    return;
319
 
  }
320
 
 
321
 
  con->options= options;
322
 
}
323
 
 
324
 
void drizzle_add_options(drizzle_st *con,
325
 
                             drizzle_options_t options)
326
 
{
327
 
  if (con == NULL)
328
 
  {
329
 
    return;
330
 
  }
331
 
 
332
 
  con->options = (drizzle_options_t)((int)con->options | (int)options);
333
 
}
334
 
 
335
 
void drizzle_remove_options(drizzle_st *con,
336
 
                                drizzle_options_t options)
337
 
{
338
 
  if (con == NULL)
339
 
  {
340
 
    return;
341
 
  }
342
 
 
343
 
  con->options = (drizzle_options_t)((int) con->options & (int)~options);
 
303
drizzle_options_st *drizzle_options_create(void)
 
304
{
 
305
  return new (std::nothrow) drizzle_options_st;
 
306
}
 
307
 
 
308
void drizzle_options_destroy(drizzle_options_st *options)
 
309
{
 
310
  delete options;
 
311
}
 
312
 
 
313
void drizzle_options_set_non_blocking(drizzle_options_st *options, bool state)
 
314
{
 
315
  if (options == NULL)
 
316
  {
 
317
    return;
 
318
  }
 
319
  options->non_blocking= state;
 
320
}
 
321
 
 
322
bool drizzle_options_get_non_blocking(drizzle_options_st *options)
 
323
{
 
324
  if (options == NULL)
 
325
  {
 
326
    return false;
 
327
  }
 
328
  return options->non_blocking;
 
329
}
 
330
 
 
331
void drizzle_options_set_raw_scramble(drizzle_options_st *options, bool state)
 
332
{
 
333
  if (options == NULL)
 
334
  {
 
335
    return;
 
336
  }
 
337
  options->raw_scramble= state;
 
338
}
 
339
 
 
340
bool drizzle_options_get_raw_scramble(drizzle_options_st *options)
 
341
{
 
342
  if (options == NULL)
 
343
  {
 
344
    return false;
 
345
  }
 
346
  return options->raw_scramble;
 
347
}
 
348
 
 
349
void drizzle_options_set_found_rows(drizzle_options_st *options, bool state)
 
350
{
 
351
  if (options == NULL)
 
352
  {
 
353
    return;
 
354
  }
 
355
  options->found_rows= state;
 
356
}
 
357
 
 
358
bool drizzle_options_get_found_rows(drizzle_options_st *options)
 
359
{
 
360
  if (options == NULL)
 
361
  {
 
362
    return false;
 
363
  }
 
364
  return options->found_rows;
 
365
}
 
366
 
 
367
void drizzle_options_set_interactive(drizzle_options_st *options, bool state)
 
368
{
 
369
  if (options == NULL)
 
370
  {
 
371
    return;
 
372
  }
 
373
  options->interactive= state;
 
374
}
 
375
 
 
376
bool drizzle_options_get_interactive(drizzle_options_st *options)
 
377
{
 
378
  if (options == NULL)
 
379
  {
 
380
    return false;
 
381
  }
 
382
  return options->interactive;
 
383
}
 
384
 
 
385
void drizzle_options_set_multi_statements(drizzle_options_st *options, bool state)
 
386
{
 
387
  if (options == NULL)
 
388
  {
 
389
    return;
 
390
  }
 
391
  options->multi_statements= state;
 
392
}
 
393
 
 
394
bool drizzle_options_get_multi_statements(drizzle_options_st *options)
 
395
{
 
396
  if (options == NULL)
 
397
  {
 
398
    return false;
 
399
  }
 
400
  return options->multi_statements;
 
401
}
 
402
 
 
403
void drizzle_options_set_auth_plugin(drizzle_options_st *options, bool state)
 
404
{
 
405
  if (options == NULL)
 
406
  {
 
407
    return;
 
408
  }
 
409
  options->auth_plugin= state;
 
410
}
 
411
 
 
412
bool drizzle_options_get_auth_plugin(drizzle_options_st *options)
 
413
{
 
414
  if (options == NULL)
 
415
  {
 
416
    return false;
 
417
  }
 
418
  return options->auth_plugin;
344
419
}
345
420
 
346
421
const char *drizzle_host(const drizzle_st *con)
610
685
    return DRIZZLE_RETURN_INVALID_ARGUMENT;
611
686
  }
612
687
 
613
 
  if (con->options & DRIZZLE_CON_READY)
 
688
  if (con->state.ready)
614
689
  {
615
690
    return DRIZZLE_RETURN_OK;
616
691
  }
617
692
 
618
693
  if (drizzle_state_none(con))
619
694
  {
620
 
    if (!(con->options & DRIZZLE_CON_RAW_PACKET))
 
695
    if (con->state.raw_packet == false)
621
696
    {
622
697
      drizzle_state_push(con, drizzle_state_handshake_server_read);
623
698
      drizzle_state_push(con, drizzle_state_packet_read);
721
796
 
722
797
  drizzle_result_st *old_result;
723
798
 
724
 
  if (!(con->options & DRIZZLE_CON_READY))
 
799
  if (con->state.ready == false)
725
800
  {
726
 
    if (con->options & DRIZZLE_CON_RAW_PACKET)
 
801
    if (con->state.raw_packet)
727
802
    {
728
803
      drizzle_set_error(con, "drizzle_command_write",
729
804
                        "connection not ready");
740
815
 
741
816
  if (drizzle_state_none(con))
742
817
  {
743
 
    if (con->options & (DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_NO_RESULT_READ))
 
818
    if (con->state.raw_packet || con->state.no_result_read)
744
819
    {
745
820
      con->result= NULL;
746
821
    }
1097
1172
    }
1098
1173
 
1099
1174
    ret= drizzle_set_events(con, POLLOUT);
1100
 
    if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING)
 
1175
    if (con->options.non_blocking)
1101
1176
    {
1102
1177
      return DRIZZLE_RETURN_IO_WAIT;
1103
1178
    }
1133
1208
  }
1134
1209
 
1135
1210
  if ((con->revents & POLLIN) == 0 &&
1136
 
      (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING))
 
1211
      (con->options.non_blocking))
1137
1212
  {
1138
1213
    /* non-blocking mode: return IO_WAIT instead of attempting to read. This
1139
1214
     * avoids reading immediately after writing a command, which typically
1225
1300
            return ret;
1226
1301
          }
1227
1302
 
1228
 
          if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING)
 
1303
          if (con->options.non_blocking)
1229
1304
          {
1230
1305
            return DRIZZLE_RETURN_IO_WAIT;
1231
1306
          }
1332
1407
          return ret;
1333
1408
        }
1334
1409
 
1335
 
        if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING)
 
1410
        if (con->options.non_blocking)
1336
1411
        {
1337
1412
          return DRIZZLE_RETURN_IO_WAIT;
1338
1413
        }