Date: Mon, 30 Jul 2007 04:58:36 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 124332 for review Message-ID: <200707300458.l6U4wauB044584@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=124332 Change 124332 by gcooper@optimus-revised_pkgtools on 2007/07/30 04:58:21 ipc items: Filling in more blanks; renaming some functions and items to be more consistent and logical. file/api.h: Add some file stuff here. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/file/api.h#1 add .. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/api.c#3 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/api.h#5 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/client.c#3 edit .. //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/server.c#3 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/api.c#3 (text+ko) ==== @@ -1,7 +1,7 @@ #include "lib/ipc/api.h" ipc_info_t * -parse_ipc_message(char header) +message_to_ipc(char header) { ipc_info_t *ipc_info = calloc(1, sizeof(ipc_info_t)); @@ -22,6 +22,7 @@ ipc_info->valid = ( !(header | IPC_MSG_IS_DEPORIGIN) && (!(header | IPC_MSG_UPDATE) || ( (header | IPC_MSG_UPDATE) && ipc_info->remove_entry )) ); ipc_info->remove_entry = (header | IPC_MSG_REMOVE_ENTRY); + ipc_info->file_entry = break; /** @@ -38,3 +39,27 @@ return ipc_info; } + +char +ipc_to_message(ipc_info_t *ipc_info) +{ + + char header; + + header = (ipc_info->message_type << IPC_MSG_TYPE_SHIFT); + + if(ipc_info->remove_entry) + header += IPC_MSG_REMOVE_ENTRY; + + if(ipc_info->file_info->exists) { + + if(ipc_info->file_info->valid_checksum) + header += IPC_MSG_VALID_CHECKSUM; + + header += IPC_MSG_FILE_EXISTS; + + } + + return header; + +} ==== //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/api.h#5 (text+ko) ==== @@ -1,6 +1,12 @@ -#ifndef __API_H +#ifndef __IPC_API_H + +#define __IPC_API_H + +#include "lib/file/api.h" + +#define SEND(SOCK, MSG) send(SOCK, MSG, sizeof(MSG)) -#define __API_H +#define RECV(SOCK, MSG) recv(SOCK, MSG, sizeof(MSG)) typedef enum { NULL_TYPE = 0, @@ -10,10 +16,17 @@ } message_type_e; typedef struct { + char path[FILENAME_MAX+1]; + char checksum[MAX_CHECKSUM_LENGTH+1]; + int exists; + int checksum_matches; +} file_info_t; + +typedef struct { + int remove_entry; + int valid; message_type_e message_type; - int valid; - int remove_entry; - int meta; + file_info_t file_info; } ipc_info_t; /** @@ -24,8 +37,8 @@ * 2 Update * 3 Remove * 4 Origin type - * 5 Valid file - * 6 Valid checksum + * 5 Checksum + * 6 File exists * * =================================================== * Category | Value | Meaning @@ -43,19 +56,20 @@ * completely remove entry * from database. * For package entries, - * set status to deinstalled - * | 0 | Do nothing (. + * set status to 'not + * installed'. + * | 0 | Do nothing. * =================================================== * Origin type | 1 | Origin. * | 0 | Deporigin. * =================================================== - * Valid file | 1 | File exists in its - * respective spot. - * | 0 | File doesn't exist. + * File exists | 1 | (Self-explanatory) + * File doesn't | 0 | + * exist * =================================================== - * Valid | 1 | Calculated checksum - * checksum matches. - * | 0 | Checksum didn't match. + * Valid | 1 | Checksum passes. + * checksum + * Bad checksum | 0 | Checksum failed. * */ @@ -74,13 +88,14 @@ #define IPC_MSG_IS_DEPORIGIN (1 << 3) -#define IPC_MSG_VALID_FILE (1 << 2) +#define IPC_MSG_FILE_EXISTS (1 << 2) #define IPC_MSG_VALID_CHECKSUM (1 << 1) #define IPC_VALID_MESSAGE 0 #define IPC_INVALID_MESSAGE 1 -ipc_info_t* parse_ipc_message(char); +ipc_info_t* message_to_ipc(char); +char ipc_to_message(ipc_info_t*); #endif ==== //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/client.c#3 (text+ko) ==== @@ -6,6 +6,8 @@ char *data_payload = (msg+1); + RECV(sock, msg); + ipc_info = parse_ipc_message(*msg); if(ipc_info->valid) { @@ -19,15 +21,12 @@ } int -client_service_ipc_send(int sock, ipc_info_t ipc_info, char *msg) +client_service_ipc_send(int sock, ipc_info_t *ipc_info, char *msg) { - if(ipc_info->valid) { + *msg = ipc_to_msg(ipc_info); -// ipc_info->valid = 0; - - } - - return (int) send(sock, req_string, sizeof(msg), MSG_OOB | MSG_EOF | MSG_NOSIGNAL); + if(SEND(sock, msg) < 0) + return -1; } ==== //depot/projects/soc2007/revised_fbsd_pkgtools/v2/lib/ipc/server.c#3 (text+ko) ==== @@ -6,7 +6,9 @@ char *data_payload = (msg+1); - ipc_info = parse_ipc_message(*msg); + RECV(sock, msg); + + ipc_info = message_to_ipc(*msg); if(ipc_info->valid) { @@ -19,15 +21,12 @@ } int -server_service_ipc_send(int sock, ipc_info_t ipc_info, char *msg) +server_service_ipc_send(int sock, ipc_info_t *ipc_info, char *msg) { - if(ipc_info->valid) { + *msg = ipc_to_message(ipc_info); -// ipc_info->valid = 0; - - } - - return (int) send(sock, req_string, sizeof(msg), MSG_OOB | MSG_EOF | MSG_NOSIGNAL); + if(SEND(sock, msg) < 0) + return -1; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707300458.l6U4wauB044584>