File: io_tryreadtimeout.c

package info (click to toggle)
libowfat 0.22-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,148 kB
  • ctags: 976
  • sloc: ansic: 10,424; makefile: 42
file content (16 lines) | stat: -rw-r--r-- 333 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <errno.h>
#include "io_internal.h"

int64 io_tryreadtimeout(int64 d,char* buf,int64 len) {
  int64 r=io_tryread(d,buf,len);
  if (r==-1) {
    tai6464 x;
    io_entry* e=array_get(&io_fds,sizeof(io_entry),d);
    taia_now(&x);
    if (!taia_less(&x,&e->timeout)) {
      errno=ETIMEDOUT;
      r=-2;
    }
  }
  return r;
}