From owner-p4-projects@FreeBSD.ORG Sat Jun 23 05:43:42 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8169216A46C; Sat, 23 Jun 2007 05:43:42 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3371F16A469 for ; Sat, 23 Jun 2007 05:43:42 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 22ACE13C43E for ; Sat, 23 Jun 2007 05:43:42 +0000 (UTC) (envelope-from andrew@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l5N5hgxC046202 for ; Sat, 23 Jun 2007 05:43:42 GMT (envelope-from andrew@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l5N5hfKg046198 for perforce@freebsd.org; Sat, 23 Jun 2007 05:43:41 GMT (envelope-from andrew@freebsd.org) Date: Sat, 23 Jun 2007 05:43:41 GMT Message-Id: <200706230543.l5N5hfKg046198@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to andrew@freebsd.org using -f From: Andrew Turner To: Perforce Change Reviews Cc: Subject: PERFORCE change 122187 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2007 05:43:43 -0000 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 #include +#include /* 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 = ""; + msg = facund_response_string(resp); + if (msg != NULL) { facund_send(conn, msg, strlen(msg)); - return; } }