Mercurial > nomad
view src/client/main.c @ 800:f679541c8142
switch to new buffer_init_static libjeffpc API
The function gained a second size argument removing the need for some
truncate calls.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Fri, 03 Apr 2020 15:54:51 -0400 |
parents | cb85a85c483c |
children | eb2ea1fc3c03 |
line wrap: on
line source
/* * Copyright (c) 2015-2020 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * Copyright (c) 2015 Holly Sipek * Copyright (c) 2016 Steve Dougherty * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <unistd.h> #include <jeffpc/error.h> #include <jeffpc/socksvc.h> #include <nomad/types.h> #include <nomad/objstore.h> #include <nomad/init.h> #include "cmds.h" #include "ohandle.h" #define CLIENT_DAEMON_PORT 2323 static void connection_acceptor(int fd, struct socksvc_stats *stats, void *arg) { struct fsconn conn; conn.fd = fd; conn.vol = NULL; inode_map_alloc(&conn.inode_map); rb_create(&conn.open_handles, ohandle_cmp, sizeof(struct ohandle), offsetof(struct ohandle, node)); buffer_init_static(&conn.rpc_buffer, conn._rpc_buffer, 0, sizeof(conn._rpc_buffer), true); cmn_err(CE_DEBUG, "%s: fd = %d, arg = %p", __func__, fd, arg); if (process_handshake(&conn)) while (process_connection(&conn)) ; ohandle_close_all(&conn); inode_map_free(&conn.inode_map); rb_destroy(&conn.open_handles); } int main(int argc, char **argv) { int ret; ret = inode_map_init(); if (ret) { cmn_err(CE_CRIT, "failed to initialize inode-map subsystem: %s", xstrerror(ret)); goto err; } ret = ohandle_init(); if (ret) { cmn_err(CE_CRIT, "failed to initialize ohandle subsystem: %s", xstrerror(ret)); goto err; } ret = objstore_init(); if (ret) { cmn_err(CE_CRIT, "objstore_init() = %d (%s)", ret, xstrerror(ret)); if (ret == ENOENT) cmn_err(CE_CRIT, "Did you set LD_LIBRARY_PATH?"); goto err; } ret = socksvc(NULL, CLIENT_DAEMON_PORT, -1, connection_acceptor, NULL); cmn_err(CE_DEBUG, "socksvc() = %d (%s)", ret, xstrerror(ret)); /* XXX: undo objstore_init() */ err: return ret; }