~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/net_serv.c

Merged in Jay's tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#define TEST_BLOCKING           8
50
50
#define MAX_PACKET_LENGTH (256L*256L*256L-1)
51
51
 
52
 
static my_bool net_write_buff(NET *net,const uchar *packet,ulong len);
 
52
static bool net_write_buff(NET *net, const unsigned char *packet, uint32_t len);
53
53
 
54
54
 
55
55
/** Init with packet info. */
56
56
 
57
 
my_bool my_net_init(NET *net, Vio* vio)
 
57
bool my_net_init(NET *net, Vio* vio)
58
58
{
59
59
  DBUG_ENTER("my_net_init");
60
60
  net->vio = vio;
93
93
 
94
94
/** Realloc the packet buffer. */
95
95
 
96
 
my_bool net_realloc(NET *net, size_t length)
 
96
bool net_realloc(NET *net, size_t length)
97
97
{
98
98
  uchar *buff;
99
99
  size_t pkt_length;
196
196
  @param clear_buffer           if <> 0, then clear all data from comm buff
197
197
*/
198
198
 
199
 
void net_clear(NET *net, my_bool clear_buffer)
 
199
void net_clear(NET *net, bool clear_buffer)
200
200
{
201
201
  size_t count;
202
 
  int ready;
 
202
  int32_t ready;
203
203
  DBUG_ENTER("net_clear");
204
204
 
205
205
  if (clear_buffer)
226
226
    {
227
227
      /* Read unblocking to clear net */
228
228
      my_bool old_mode;
229
 
      if (!vio_blocking(net->vio, FALSE, &old_mode))
 
229
      if (!vio_blocking(net->vio, false, &old_mode))
230
230
      {
231
231
        while ((long) (count= vio_read(net->vio, net->buff,
232
232
                                       (size_t) net->max_packet)) > 0)
233
233
          DBUG_PRINT("info",("skipped %ld bytes from file: %s",
234
234
                             (long) count, vio_description(net->vio)));
235
 
        vio_blocking(net->vio, TRUE, &old_mode);
 
235
        vio_blocking(net->vio, true, &old_mode);
236
236
      }
237
237
    }
238
238
#endif /* NET_DATA_IS_READY_CAN_RETURN_MINUS_ONE */
245
245
 
246
246
/** Flush write_buffer if not empty. */
247
247
 
248
 
my_bool net_flush(NET *net)
 
248
bool net_flush(NET *net)
249
249
{
250
250
  my_bool error= 0;
251
251
  DBUG_ENTER("net_flush");
276
276
    If compression is used the original package is modified!
277
277
*/
278
278
 
279
 
my_bool
 
279
bool
280
280
my_net_write(NET *net,const uchar *packet,size_t len)
281
281
{
282
282
  uchar buff[NET_HEADER_SIZE];
336
336
    1   error
337
337
*/
338
338
 
339
 
my_bool
 
339
bool
340
340
net_write_command(NET *net,uchar command,
341
341
                  const uchar *header, size_t head_len,
342
342
                  const uchar *packet, size_t len)
402
402
    1
403
403
*/
404
404
 
405
 
static my_bool
406
 
net_write_buff(NET *net, const uchar *packet, ulong len)
 
405
static bool
 
406
net_write_buff(NET *net, const unsigned char *packet, uint32_t len)
407
407
{
408
408
  ulong left_length;
409
409
  if (net->compress && net->max_packet > MAX_PACKET_LENGTH)
518
518
        if (!thr_alarm(&alarmed, net->write_timeout, &alarm_buff))
519
519
        {                                       /* Always true for client */
520
520
          my_bool old_mode;
521
 
          while (vio_blocking(net->vio, TRUE, &old_mode) < 0)
 
521
          while (vio_blocking(net->vio, true, &old_mode) < 0)
522
522
          {
523
523
            if (vio_should_retry(net->vio) && retry_count++ < net->retry_count)
524
524
              continue;
725
725
  net->read_pos points to the read data.
726
726
*/
727
727
 
728
 
ulong
 
728
uint32_t
729
729
my_net_read(NET *net)
730
730
{
731
731
  size_t len, complen;