Beispiel #1
0
void read_cb (int sock, short what, void *arg) 
{
    //printf ("in function read_cb\n");
    int block_size = 512;
    char buf[512];
    bzero (buf, 512);

    int nbyte = read (sock, buf, block_size);
    if (nbyte > 0) {
	//fprintf (stdout, "read : %s\n", buf);
	if (read_done (buf))
	    fin += 1;
    }
    else {
	fprintf (stderr, "read failed\n");
    }

    return ;
}
Beispiel #2
0
void* consumer(void* ptr)
{
    Buffer* buf = (Buffer*)ptr;
    while (1) {
        int slot = read_start(buf);
        if (slot == -1) {
            printf(ANSI_RED"consumer: no data in queue...waiting"ANSI_NORMAL"\n");
            usleep(consumer_delay);
            continue;
        }
        
        //printf(ANSI_RED"consumer: slot %d"ANSI_NORMAL"\n", slot);
        buffer_print(buf);
        usleep(consume_duration);
        read_done(buf);
        buffer_print(buf);
    }

    return 0;
}
Beispiel #3
0
/* Read a specified number of bytes into a buffer from the given NFS file */
void
nfsfs_read(pid_t pid, VNode self, fildes_t file, L4_Word_t pos,
		char *buf, size_t nbyte, void (*read_done)(pid_t pid,
			VNode self, fildes_t file, L4_Word_t pos, char *buf, size_t nbyte, int status)) {
	dprintf(1, "*** nfsfs_read: %p, %d, %d, %p, %d\n", self, file, pos, buf, nbyte);

	NFS_File *nf = (NFS_File *) self->extra;	
	if (self == NULL || nf == NULL) {
		dprintf(0, "!!! nfsfs_read: Invalid NFS file (p %d, f %d), no nfs struct!\n",
				pid, file);
		read_done(pid, self, file, pos, buf, 0, SOS_VFS_NOFILE);
		return;
	}

	NFS_ReadRequest *rq = (NFS_ReadRequest *) create_request(RT_READ, self, pid);
	rq->file = file;
	rq->buf = buf;
	rq->pos = pos;
	rq->nbyte = nbyte;
	rq->read_done = read_done;

	check_request((NFS_BaseRequest *) rq);
}