~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/net_serv.c

  • Committer: Monty Taylor
  • Date: 2008-09-15 00:46:33 UTC
  • mfrom: (383.1.55 client-split)
  • Revision ID: monty@inaugust.com-20080915004633-fmjw27fi41cxs35w
Merged from client-split.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 */
20
20
 
21
21
#include <drizzled/global.h>
22
 
#include <drizzle.h>
 
22
#include "libdrizzle.h"
23
23
#include <libdrizzle/errmsg.h>
24
24
#include <vio/violite.h>
25
25
#include <signal.h>
74
74
  return(0);
75
75
}
76
76
 
 
77
bool net_init_sock(NET * net, int sock, int flags)
 
78
{
 
79
 
 
80
  Vio *vio_tmp= vio_new(sock, VIO_TYPE_TCPIP, flags);
 
81
  if (vio_tmp == NULL)
 
82
    return true;
 
83
  else
 
84
    if (my_net_init(net, vio_tmp))
 
85
    {
 
86
      /* Only delete the temporary vio if we didn't already attach it to the
 
87
       * NET object.
 
88
       */
 
89
      if (vio_tmp && (net->vio != vio_tmp))
 
90
        vio_delete(vio_tmp);
 
91
      else
 
92
      {
 
93
        (void) shutdown(sock, SHUT_RDWR);
 
94
        (void) close(sock);
 
95
      }
 
96
      return true;
 
97
    }
 
98
  return false;
 
99
}
77
100
 
78
101
void net_end(NET *net)
79
102
{
83
106
  return;
84
107
}
85
108
 
 
109
void net_close(NET *net)
 
110
{
 
111
  if (net->vio != NULL)
 
112
  {
 
113
    vio_delete(net->vio);
 
114
    net->vio= 0;
 
115
  }
 
116
}
 
117
 
 
118
bool net_peer_addr(NET *net, char *buf, uint16_t *port, size_t buflen)
 
119
{
 
120
  return vio_peer_addr(net->vio, buf, port, buflen);
 
121
}
 
122
 
 
123
void net_keepalive(NET *net, bool flag)
 
124
{
 
125
  vio_keepalive(net->vio, flag);
 
126
}
 
127
 
 
128
int net_get_sd(NET *net)
 
129
{
 
130
  return net->vio->sd;
 
131
}
 
132
 
 
133
bool net_should_close(NET *net)
 
134
{
 
135
  return net->error || (net->vio == 0);
 
136
}
 
137
 
 
138
bool net_more_data(NET *net)
 
139
{
 
140
  return (net->vio == 0 || net->vio->read_pos < net->vio->read_end);
 
141
}
86
142
 
87
143
/** Realloc the packet buffer. */
88
144