~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/net_serv.c

  • Committer: Brian Aker
  • Date: 2008-07-18 18:40:48 UTC
  • Revision ID: brian@tangent.org-20080718184048-y7ai3bco6osnzvcy
Set timeouts for writes as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
434
434
  const uchar *pos,*end;
435
435
  uint retry_count= 0;
436
436
 
 
437
  /* Backup of the original SO_RCVTIMEO timeout */
 
438
  struct timeval backtime;
 
439
  int error;
 
440
 
437
441
  if (net->error == 2)
438
442
    DBUG_RETURN(-1);                            /* socket can't be used */
439
443
 
463
467
    packet= b;
464
468
  }
465
469
 
 
470
  /* Check for error, currently assert */
 
471
  if (net->write_timeout)
 
472
  {
 
473
    struct timeval waittime;
 
474
    socklen_t length;
 
475
 
 
476
    waittime.tv_sec= net->write_timeout;
 
477
    waittime.tv_usec= 0;
 
478
 
 
479
    memset(&backtime, 0, sizeof(struct timeval));
 
480
    length= sizeof(struct timeval);
 
481
    error= getsockopt(net->vio->sd, SOL_SOCKET, SO_RCVTIMEO, 
 
482
                      &backtime, &length);
 
483
    if (error != 0)
 
484
    {
 
485
      perror("getsockopt");
 
486
      assert(error == 0);
 
487
    }
 
488
    error= setsockopt(net->vio->sd, SOL_SOCKET, SO_RCVTIMEO, 
 
489
                      &waittime, (socklen_t)sizeof(struct timeval));
 
490
    assert(error == 0);
 
491
  }
466
492
  pos= packet;
467
493
  end=pos+len;
468
494
  /* Loop until we have read everything */
514
540
    my_free((char*) packet,MYF(0));
515
541
  net->reading_or_writing=0;
516
542
 
 
543
  if (net->write_timeout)
 
544
    error= setsockopt(net->vio->sd, SOL_SOCKET, SO_RCVTIMEO, 
 
545
                      &backtime, (socklen_t)sizeof(struct timeval));
 
546
 
517
547
  DBUG_RETURN(((int) (pos != end)));
518
548
}
519
549