Date: Sat, 23 Jun 2007 05:43:41 GMT From: Andrew Turner <andrew@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 122187 for review Message-ID: <200706230543.l5N5hfKg046198@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122187 Change 122187 by andrew@andrew_hermies on 2007/06/23 05:42:41 Send the response from the request handler to the front end Support the ping request with a pong response Affected files ... .. //depot/projects/soc2007/andrew-update/backend/facund-be.c#9 edit .. //depot/projects/soc2007/andrew-update/lib/facund_server.c#9 edit Differences ... ==== //depot/projects/soc2007/andrew-update/backend/facund-be.c#9 (text+ko) ==== @@ -47,6 +47,7 @@ #include <facund_connection.h> #include <facund_object.h> +#include <facund_response.h> /* Check if there are updates every 30min */ static const time_t default_check_period = 30 * 60; @@ -263,12 +264,15 @@ } static struct facund_response * -facund_call_ping(const char *id, struct facund_object *obj) +facund_call_ping(const char *id, struct facund_object *obj __unused) { - printf("CALL: ping\nID: %s\nArgs:\n", id); - facund_object_print(obj); - putchar('\n'); - return NULL; + struct facund_response *resp; + struct facund_object *pong; + + pong = facund_object_new_string(); + facund_object_set_string(pong, "pong"); + resp = facund_response_new(id, 0, "No error", pong); + return resp; } int ==== //depot/projects/soc2007/andrew-update/lib/facund_server.c#9 (text+ko) ==== @@ -37,6 +37,7 @@ #include "facund_connection.h" #include "facund_object.h" +#include "facund_response.h" #include "facund_private.h" #define BUF_SIZE 128 @@ -127,10 +128,14 @@ facund_server_call(struct facund_conn *conn, const char *name, const char *id, struct facund_object *arg) { + const char *msg; + struct facund_response *resp; facund_call_cb *cb; DBT key, data; int ret; + resp = NULL; + /* Find the callback and execute it if it exists */ key.data = __DECONST(void *, name); key.size = (strlen(name) + 1) * sizeof(char); @@ -139,16 +144,15 @@ /* Get the callback and execute it */ cb = *(facund_call_cb **)data.data; assert(cb != NULL); - cb(id, arg); + resp = cb(id, arg); + } else { /* TODO: send a bad request response */ } - /* This is not really a valid command. It is just used for testing */ - if (strcmp(name, "ping") == 0) { - const char *msg = "<pong/>"; + msg = facund_response_string(resp); + if (msg != NULL) { facund_send(conn, msg, strlen(msg)); - return; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706230543.l5N5hfKg046198>