~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzleclient/net_serv.c

  • Committer: Monty Taylor
  • Date: 2009-02-08 11:04:34 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mordred@inaugust.com-20090208110434-dul9atfu1mzq3wd0
Renamed vio.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
  if (vio != 0)                    /* If real connection */
71
71
  {
72
 
    net->fd  = vio_fd(vio);            /* For perl DBI/DBD */
73
 
    vio_fastsend(vio);
 
72
    net->fd  = drizzleclient_vio_fd(vio);            /* For perl DBI/DBD */
 
73
    drizzleclient_vio_fastsend(vio);
74
74
  }
75
75
  return(0);
76
76
}
78
78
bool net_init_sock(NET * net, int sock, int flags)
79
79
{
80
80
 
81
 
  Vio *vio_tmp= vio_new(sock, VIO_TYPE_TCPIP, flags);
82
 
  if (vio_tmp == NULL)
 
81
  Vio *drizzleclient_vio_tmp= drizzleclient_vio_new(sock, VIO_TYPE_TCPIP, flags);
 
82
  if (drizzleclient_vio_tmp == NULL)
83
83
    return true;
84
84
  else
85
 
    if (drizzleclient_net_init(net, vio_tmp))
 
85
    if (drizzleclient_net_init(net, drizzleclient_vio_tmp))
86
86
    {
87
87
      /* Only delete the temporary vio if we didn't already attach it to the
88
88
       * NET object.
89
89
       */
90
 
      if (vio_tmp && (net->vio != vio_tmp))
91
 
        vio_delete(vio_tmp);
 
90
      if (drizzleclient_vio_tmp && (net->vio != drizzleclient_vio_tmp))
 
91
        drizzleclient_vio_delete(drizzleclient_vio_tmp);
92
92
      else
93
93
      {
94
94
        (void) shutdown(sock, SHUT_RDWR);
111
111
{
112
112
  if (net->vio != NULL)
113
113
  {
114
 
    vio_delete(net->vio);
 
114
    drizzleclient_vio_delete(net->vio);
115
115
    net->vio= 0;
116
116
  }
117
117
}
118
118
 
119
119
bool net_peer_addr(NET *net, char *buf, uint16_t *port, size_t buflen)
120
120
{
121
 
  return vio_peer_addr(net->vio, buf, port, buflen);
 
121
  return drizzleclient_vio_peer_addr(net->vio, buf, port, buflen);
122
122
}
123
123
 
124
124
void net_keepalive(NET *net, bool flag)
125
125
{
126
 
  vio_keepalive(net->vio, flag);
 
126
  drizzleclient_vio_keepalive(net->vio, flag);
127
127
}
128
128
 
129
129
int net_get_sd(NET *net)
227
227
    while (net_data_is_ready(net->vio->sd) > 0)
228
228
    {
229
229
      /* The socket is ready */
230
 
      if (vio_read(net->vio, net->buff,
 
230
      if (drizzleclient_vio_read(net->vio, net->buff,
231
231
                   (size_t) net->max_packet) <= 0)
232
232
      {
233
233
        net->error= 2;
549
549
  while (pos != end)
550
550
  {
551
551
    assert(pos);
552
 
    if ((long) (length= vio_write(net->vio, pos, (size_t) (end-pos))) <= 0)
 
552
    if ((long) (length= drizzleclient_vio_write(net->vio, pos, (size_t) (end-pos))) <= 0)
553
553
    {
554
 
      const bool interrupted= vio_should_retry(net->vio);
 
554
      const bool interrupted= drizzleclient_vio_should_retry(net->vio);
555
555
      /*
556
556
        If we read 0, or we were interrupted this means that
557
557
        we need to switch to blocking mode and wait until the timeout
561
561
      {
562
562
        bool old_mode;
563
563
 
564
 
        while (vio_blocking(net->vio, true, &old_mode) < 0)
 
564
        while (drizzleclient_vio_blocking(net->vio, true, &old_mode) < 0)
565
565
        {
566
 
          if (vio_should_retry(net->vio) && retry_count++ < net->retry_count)
 
566
          if (drizzleclient_vio_should_retry(net->vio) && retry_count++ < net->retry_count)
567
567
            continue;
568
568
          net->error= 2;                     /* Close socket */
569
569
          net->last_errno= CR_NET_PACKET_TOO_LARGE;
578
578
          continue;
579
579
      }
580
580
 
581
 
      if (vio_errno(net->vio) == EINTR)
 
581
      if (drizzleclient_vio_errno(net->vio) == EINTR)
582
582
      {
583
583
        continue;
584
584
      }
667
667
    while (remain > 0)
668
668
    {
669
669
      /* First read is done with non blocking mode */
670
 
      if ((long) (length= vio_read(net->vio, pos, remain)) <= 0L)
 
670
      if ((long) (length= drizzleclient_vio_read(net->vio, pos, remain)) <= 0L)
671
671
      {
672
 
        const bool interrupted = vio_should_retry(net->vio);
 
672
        const bool interrupted = drizzleclient_vio_should_retry(net->vio);
673
673
 
674
674
        if (interrupted)
675
675
        {                    /* Probably in MIT threads */
676
676
          if (retry_count++ < net->retry_count)
677
677
            continue;
678
678
        }
679
 
        if (vio_errno(net->vio) == EINTR)
 
679
        if (drizzleclient_vio_errno(net->vio) == EINTR)
680
680
        {
681
681
          continue;
682
682
        }
683
683
        len= packet_error;
684
684
        net->error= 2;                /* Close socket */
685
 
        net->last_errno= (vio_was_interrupted(net->vio) ?
 
685
        net->last_errno= (drizzleclient_vio_was_interrupted(net->vio) ?
686
686
                          CR_NET_READ_INTERRUPTED :
687
687
                          CR_NET_READ_ERROR);
688
688
        ER(net->last_errno);
914
914
  net->read_timeout= timeout;
915
915
#ifndef __sun
916
916
  if (net->vio)
917
 
    vio_timeout(net->vio, 0, timeout);
 
917
    drizzleclient_vio_timeout(net->vio, 0, timeout);
918
918
#endif
919
919
  return;
920
920
}
925
925
  net->write_timeout= timeout;
926
926
#ifndef __sun
927
927
  if (net->vio)
928
 
    vio_timeout(net->vio, 1, timeout);
 
928
    drizzleclient_vio_timeout(net->vio, 1, timeout);
929
929
#endif
930
930
  return;
931
931
}