~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to vio/vio.c

  • Committer: Brian Aker
  • Date: 2008-07-16 01:30:24 UTC
  • Revision ID: brian@tangent.org-20080716013024-nmnogwdpa459jrch
First pass of cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 */
28
28
 
29
29
static void vio_init(Vio* vio, enum enum_vio_type type,
30
 
                     my_socket sd, HANDLE hPipe, uint flags)
 
30
                     my_socket sd, uint32_t flags)
31
31
{
32
32
#ifndef HAVE_VIO_READ_BUFF
33
33
  flags&= ~VIO_BUFFERED_READ;
35
35
  bzero((char*) vio, sizeof(*vio));
36
36
  vio->type     = type;
37
37
  vio->sd       = sd;
38
 
  vio->hPipe    = hPipe;
39
 
  vio->localhost= flags & VIO_LOCALHOST;
40
38
  if ((flags & VIO_BUFFERED_READ) &&
41
39
      !(vio->read_buffer= (char*)my_malloc(VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
42
40
    flags&= ~VIO_BUFFERED_READ;
61
59
/* Reset initialized VIO to use with another transport type */
62
60
 
63
61
void vio_reset(Vio* vio, enum enum_vio_type type,
64
 
               my_socket sd, HANDLE hPipe, uint flags)
 
62
               my_socket sd, uint flags)
65
63
{
66
64
  my_free(vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
67
 
  vio_init(vio, type, sd, hPipe, flags);
 
65
  vio_init(vio, type, sd, flags);
68
66
}
69
67
 
70
68
 
76
74
 
77
75
  if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
78
76
  {
79
 
    vio_init(vio, type, sd, 0, flags);
80
 
    sprintf(vio->desc,
81
 
            (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
82
 
            vio->sd);
83
 
#if !defined(NO_FCNTL_NONBLOCK)
 
77
    vio_init(vio, type, sd, flags);
 
78
    sprintf(vio->desc, "TCP/IP (%d)", vio->sd);
84
79
    /*
85
80
      We call fcntl() to set the flags and then immediately read them back
86
81
      to make sure that we and the system are in agreement on the state of
93
88
    */
94
89
    fcntl(sd, F_SETFL, 0);
95
90
    vio->fcntl_mode= fcntl(sd, F_GETFL);
96
 
#elif defined(HAVE_SYS_IOCTL_H)                 /* hpux */
97
 
    /* Non blocking sockets doesn't work good on HPUX 11.0 */
98
 
    (void) ioctl(sd,FIOSNBIO,0);
99
 
    vio->fcntl_mode &= ~O_NONBLOCK;
100
 
#endif
101
91
  }
102
92
  return vio;
103
93
}
111
101
  if (vio->type != VIO_CLOSED)
112
102
    vio->vioclose(vio);
113
103
  my_free((uchar*) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
114
 
  my_free((uchar*) vio,MYF(0));
 
104
  my_free((uchar*) vio, MYF(0));
115
105
}
116
106
 
117
107