From dean-list-tux-list@arctic.org Wed Feb 21 21:45:08 2001 Date: Wed, 21 Feb 2001 21:27:10 -0800 (PST) From: dean gaudet To: tux-list@redhat.com Subject: [patch] Re: SPECweb99: CAD_u module X-comment: visit http://arctic.org/~dean/legal for information regarding copyright and disclaimer. so here's a patch to CAD_u.c including the earlier api changes, a bugfix i posted a couple weeks back, plus the POST api changes ingo just suggested. i took the liberty of adding a version number. -dean --- CAD_u.c.orig Tue Nov 28 09:03:46 2000 +++ CAD_u.c Wed Feb 21 21:13:06 2001 @@ -5,6 +5,11 @@ * * CAD.c: Implementation of the SPECweb99 dynamic application * using TUXAPI. + * + * 1.0 - version from the Dell-20001128.tar.gz submitted to spec + * 1.1 - tux_up/tux_down renamed to TUXAPI_up/_down + * - fixed missing perms on postlog open() (dean gaudet) + * 1.2 - updated do_POST() for tux-2.0.7 POST API */ #include #include @@ -358,7 +363,7 @@ if (postlog_file != -1) close(postlog_file); - postlog_file = open(POSTLOG, O_CREAT|O_TRUNC|O_RDWR); + postlog_file = open(POSTLOG, O_CREAT|O_TRUNC|O_RDWR, 0666); if ((postlog_file) == -1) return send_err(req, "CAD: could not open POST-log!\n"); sprintf(count_buf, "%10d\n", 0); @@ -495,9 +500,9 @@ if (TOKEN_EQUAL(query, COMMAND_FETCH)) { int ret; - tux_down(postlog_sem); + TUXAPI_down(postlog_sem); ret = send_postlog(req); - tux_up(postlog_sem); + TUXAPI_up(postlog_sem); return ret; } return send_err(req,"CAD: got invalid command!\n"); @@ -633,15 +638,21 @@ static int do_POST (user_req_t *req) { int dir = -1, class = -1, num = -1, client = -1; - char buf[400], count_buf[10], *tmp; + char post_data[301], buf[400], count_buf[10], *tmp; char urlroot[100]; CAD_t *CADp = (CAD_t *) req->private; char *curr; int size, ret; - curr = req->post_data; - if (!curr) + req->object_addr = post_data; + req->objectlen = sizeof(post_data)-1; + ret = tux(TUX_ACTION_READ_POST_DATA, req); + if (ret < 0) + BUG(); + post_data[req->objectlen] = 0; + if (!req->objectlen) goto parse_error; + curr = post_data; #define POST_URLROOT "urlroot=" #define POST_CLASS "class=" @@ -689,7 +700,7 @@ * Acquire lock guaranteeing atomic operations * on the postlog file. */ - tux_down(postlog_sem); + TUXAPI_down(postlog_sem); if ((postlog_file) == -1) open_postlog_file(req); if (postlog_file == -1) @@ -705,7 +716,7 @@ tmp += sprintf(tmp, "%10d %10ld %10d %5d %2d %2d %10d %-60.60s %10d %10d\n", atoi(count_buf), time(NULL), this_pid, dir, class, num, client, CADp->ad_filename, this_pid, CADp->user_id + 10000); ret = write(postlog_file, buf, tmp-buf); - tux_up(postlog_sem); + TUXAPI_up(postlog_sem); if (ret != tmp-buf) goto sock_write_error; @@ -718,7 +729,7 @@ return send_err(req,"CAD: error while parsing POST request!\n"); file_error: - tux_up(postlog_sem); + TUXAPI_up(postlog_sem); return send_err(req, "CAD: POST-log file error!\n"); sock_write_error: