From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/common Module.cpp executils.cpp
Date: 2 Jun 2007 04:28:49 -0000 [thread overview]
Message-ID: <20070602042849.17702.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Branch: EXPERIMENTAL
Changes by: rmccabe at sourceware.org 2007-06-02 04:28:49
Modified files:
ricci/common : Module.cpp executils.cpp
Log message:
be smarter about parsing incoming requests
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Module.cpp.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.5.8.1&r2=1.5.8.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/executils.cpp.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.8&r2=1.8.2.1
--- conga/ricci/common/Module.cpp 2007/06/01 23:12:22 1.5.8.1
+++ conga/ricci/common/Module.cpp 2007/06/02 04:28:48 1.5.8.2
@@ -253,56 +253,70 @@
int
__stdin_out_module_driver(Module& module)
{
- unsigned int time_beg = time_mil();
- String data;
+ unsigned int time_beg = time_mil();
+ String data;
- while (time_mil() < time_beg + timeout) {
- poll_fd poll_data;
- poll_data.fd = 0;
- poll_data.events = POLLIN;
- poll_data.revents = 0;
+ while (time_mil() < time_beg + timeout) {
+ poll_fd poll_data;
+ poll_data.fd = 0;
+ poll_data.events = POLLIN;
+ poll_data.revents = 0;
- // wait for events
- int ret = poll(&poll_data, 1, 500);
- if (ret == 0) {
- // continue waiting
- continue;
- } else if (ret == -1) {
- if (errno == EINTR)
- continue;
- else
- throw String("poll() error");
- }
-
- // process event
- if (poll_data.revents & POLLIN) {
- char buff[4096];
- int ret = read(poll_data.fd, buff, sizeof(buff));
- if (ret == -1) {
- if (errno == EINTR)
- continue;
- throw String("error reading stdin");
- }
- try {
- data.append(buff, ret);
- shred(buff, sizeof(buff));
- XMLObject request = parseXML(data);
- XMLObject response = module.process(request);
- cout << generateXML(response) << endl;
- return 0;
- } catch ( ... ) {
- shred(buff, sizeof(buff));
- }
- continue;
- }
- if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL))
- throw String("stdin error???");
+ // wait for events
+ int ret = poll(&poll_data, 1, 500);
+
+ if (ret == 0) {
+ /*
+ ** We may be done if the total input length is a multiple of
+ ** the buffer size.
+ */
+ if (data.length() > 0) {
+ try {
+ XMLObject request = parseXML(data);
+ XMLObject response = module.process(request);
+ cout << generateXML(response) << endl;
+ return 0;
+ } catch ( ... ) { }
+ }
+ // continue waiting
+ continue;
+ } else if (ret == -1) {
+ if (errno == EINTR)
+ continue;
+ else
+ throw String("poll() error: ") + String(strerror(errno));
+ }
- } // while
+ // process event
+ if (poll_data.revents & POLLIN) {
+ char buff[4096];
+ int ret = read(poll_data.fd, buff, sizeof(buff));
+ if (ret == -1) {
+ if (errno == EINTR)
+ continue;
+ throw String("error reading stdin: ") + String(strerror(errno));
+ }
+
+ if ((size_t) ret < sizeof(buff)) {
+ try {
+ data.append(buff, ret);
+ shred(buff, sizeof(buff));
+ XMLObject request = parseXML(data);
+ XMLObject response = module.process(request);
+ cout << generateXML(response) << endl;
+ return 0;
+ } catch ( ... ) {
+ shred(buff, sizeof(buff));
+ }
+ }
+ continue;
+ }
+ if (poll_data.revents & (POLLERR | POLLHUP | POLLNVAL))
+ throw String("stdin error: ") + String(strerror(errno));
+ } // while
// cout << data << endl;
-
- throw String("invalid input");
+ throw String("invalid input");
}
--- conga/ricci/common/executils.cpp 2007/03/05 20:06:50 1.8
+++ conga/ricci/common/executils.cpp 2007/06/02 04:28:48 1.8.2.1
@@ -218,7 +218,7 @@
if (poll_info.revents & POLLIN) {
try {
- char data_in[1024];
+ char data_in[4096];
int ret = read(fd, data_in, sizeof(data_in));
if (ret < 0)
return;
reply other threads:[~2007-06-02 4:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070602042849.17702.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.