Thomas Fletcher
|
RE: RE: RE: io write functions.
|
Thomas Fletcher
11/26/2007 9:25 AM
post2928
|
RE: RE: RE: io write functions.
> -----Original Message-----
> From: Jeffry Molanus [mailto:ing.gila@gmail.com]
> Sent: November 26, 2007 8:45 AM
> To: ostech-core_os
> Subject: Re: RE: RE: io write functions.
>
> The cp utility copies the data in 'parts' does it not? i.e
write() --> MsgSend w/ IO_WRITE --> your handler.
However many times the client (cp in this case) calls write() is
how many times you are going to get write messages.
> iofuncs_attr.nbytes=4096;
>
> So if a file is 2*4096 large; It would peform the write
> handler 2 times and I have to reply 2 times, no? I might not
> just understand this fully yet, so here is the code (relevant
> bits) of the io_write handler.
You need to reply for every write ... with the number of bytes
that you have written.
> int io_write (resmgr_context_t *ctp, io_write_t *msg,
> RESMGR_OCB_T *ocb)
> {
> int status;
> char *buf;
>
> buf = (char *) malloc(msg->i.nbytes + 1);
> if (buf == NULL)
> return(ENOMEM);
>
> resmgr_msgread(ctp, buf, msg->i.nbytes, sizeof(msg->i));
> memcpy(d->prog_file + offset ,buf,msg->i.nbytes);
> offset +=msg->i.nbytes;
> d->prog_size+=msg->i.nbytes;
>
> return (_RESMGR_NPARTS (0));
>
> You mean I should not return with _RESMGR_NPARTS(0) right now?
I'm assuming that you do something with buf and you have some
options:
Option 1:
- Reply only after you have finished processing the write. Not knowing
what your end goal is here, I don't know if this is applicable to you
or not. You can save the rcvid information and simply return with
RESMGR_NOREPLY to indicate that you don't want to framework to reply
to the client, and then after you are finished processing the write
data (ie buf) then you can do a MsgReply() yourself to unblock the
client.
Option 2:
- You keep going the way you are going and then hold off replying to
the client when they perform a close until you have finished processing
all of the data that they have sent to you. In this case you need to
put some logic into the close_ocb handler.
There are other options, but to keep it simple, those would be the first
two approaches I'd consider.
Hope this helps,
Thomas
|
|
|