~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to vio/viosocket.c

  • Committer: Brian Aker
  • Date: 2008-08-08 15:38:16 UTC
  • Revision ID: brian@tangent.org-20080808153816-858pru9i35hq1rgz
Merging up a bunch of assert() and cleanup of my_sock typedef

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
*/
22
22
 
23
23
#include "vio_priv.h"
 
24
#include <sys/socket.h>
24
25
 
25
26
int vio_errno(Vio *vio __attribute__((unused)))
26
27
{
209
210
  return vio->type;
210
211
}
211
212
 
212
 
my_socket vio_fd(Vio* vio)
 
213
int vio_fd(Vio* vio)
213
214
{
214
215
  return vio->sd;
215
216
}
243
244
 
244
245
/* Return 0 if there is data to be read */
245
246
 
246
 
bool vio_poll_read(Vio *vio,uint timeout)
 
247
bool vio_poll_read(Vio *vio, int32_t timeout)
247
248
{
248
249
  struct pollfd fds;
249
250
  int res;
270
271
  return false;
271
272
}
272
273
 
273
 
void vio_timeout(Vio *vio, uint which, uint timeout)
 
274
void vio_timeout(Vio *vio, bool is_sndtimeo, int32_t timeout)
274
275
{
275
 
  int r;
 
276
  int error;
276
277
 
277
278
  /* POSIX specifies time as struct timeval. */
278
279
  struct timeval wait_timeout;
279
280
  wait_timeout.tv_sec= timeout;
280
281
  wait_timeout.tv_usec= 0;
281
282
 
282
 
  r= setsockopt(vio->sd, SOL_SOCKET, which ? SO_SNDTIMEO : SO_RCVTIMEO,
283
 
                IF_WIN(const char*, const void*)&wait_timeout,
284
 
                sizeof(wait_timeout));
285
 
  if (r != 0)
 
283
  assert(timeout >= 0 && timeout <= INT32_MAX);
 
284
  assert(vio->sd != -1);
 
285
  error= setsockopt(vio->sd, SOL_SOCKET, is_sndtimeo ? SO_SNDTIMEO : SO_RCVTIMEO,
 
286
                    &wait_timeout,
 
287
                    (socklen_t)sizeof(struct timeval));
 
288
  if (error != 0)
286
289
  {
287
290
    perror("setsockopt");
288
 
    assert(r == 0);
 
291
    assert(error == 0);
289
292
  }
290
293
}