| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
* Marek Habersack <grendel@caudium.net> wrote:
> if (rval == REQ_STATIC) {
> req->event = 1;
> do_syslog("Static request, getting the object (%s)", req->objectname);
> rval = tux(TUX_ACTION_GET_OBJECT, req);
> if (rval < 0 || req->error) {
> req->event = 2;
> if (content_type(req) == CONTENT_NOTIFY)
> return send_failure(req, LOG_ERR_OBJECT_NOT_FOUND);
>
> goto abort;
> }
> return rval;
> }
This code doesnt handle events properly. When tux() returns there might
be another request active (with a different ->priv value) - you need to
return so that your event loop can be re-called with the proper request
pointer.
the req->event code can be used to distinguish between the various
phases a particular request is in. (you can also track your request's
state via the ->priv pointer) demo2.c shows a 3-phase request. (for
simplicity the demo code uses write() but a truly atomic module should
use TUX_ACTION_SEND_BUFFER to write to the socket. A write(), if the
send buffers are set to be small on your system, might block your thread
and hence all requests might be blocked by the remote client.)
it all looks a bit complex but that is how event-based programming is
...
Ingo
[Older Fedora Users Mail] [Home] [Fedora Legacy] [Fedora Desktop] [iPod Nano] [ATA RAID] [Fedora Bible] [Fedora Marketing] [Fedora Mentors] [Fedora Packaging] [Fedora SELinux] [Big List of Linux Books] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools] [Fedora Docs]