summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 11:35:01 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-31 11:35:01 +0000
commit458d313a17888af10114daaab32b1eaa1288e909 (patch)
treea73232f19d3b9ee1b67f0df8695f71f3806a384f /TOOLS
parentf19318b6c01541eb22cd81d8dc624353100593b7 (diff)
downloadmpv-458d313a17888af10114daaab32b1eaa1288e909.tar.bz2
mpv-458d313a17888af10114daaab32b1eaa1288e909.tar.xz
non-blocked disk reading test
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@917 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/blocking.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/TOOLS/blocking.c b/TOOLS/blocking.c
new file mode 100644
index 0000000000..d7fb6aaf83
--- /dev/null
+++ b/TOOLS/blocking.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define BUFFSIZE (32*65536)
+
+unsigned char *buffer[1];
+
+int main(int argc,char* argv[]){
+
+ fd_set rfds;
+ struct timeval tv;
+ int retval;
+ int in_fd=0; // stdin
+
+ buffer[0]=malloc(BUFFSIZE);
+
+ if(argc>1) in_fd=open(argv[1],O_RDONLY|O_NONBLOCK);
+
+while(1){
+ FD_ZERO(&rfds); FD_SET(in_fd, &rfds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ retval = select(in_fd+1, &rfds, NULL, NULL, &tv);
+
+ if (retval){
+ if(FD_ISSET(in_fd, &rfds)){
+ // we can read input.
+ int len;
+ fprintf(stderr,"r");fflush(stderr);
+ len=read(in_fd,buffer[0],BUFFSIZE);
+ fprintf(stderr,"(%d)",len);fflush(stderr);
+ }
+ } else {
+ fprintf(stderr,".");fflush(stderr);
+ }
+
+ fprintf(stderr,"\n");fflush(stderr);
+}
+
+return 0;
+}
+