gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r21176 - gnunet/src/lockmanager


From: gnunet
Subject: [GNUnet-SVN] r21176 - gnunet/src/lockmanager
Date: Thu, 26 Apr 2012 18:17:49 +0200

Author: harsha
Date: 2012-04-26 18:17:49 +0200 (Thu, 26 Apr 2012)
New Revision: 21176

Added:
   gnunet/src/lockmanager/Makefile.am
   gnunet/src/lockmanager/gnunet-service-lockmanager.c
   gnunet/src/lockmanager/lockmanager.conf.in
   gnunet/src/lockmanager/lockmanager.h
   gnunet/src/lockmanager/lockmanager_api.c
Modified:
   gnunet/src/lockmanager/
   gnunet/src/lockmanager/README
Log:
-lockmanager build skeleton


Property changes on: gnunet/src/lockmanager
___________________________________________________________________
Added: svn:ignore
   + Makefile
Makefile.in
lockmanager.conf
gnunet-service-lockmanager
.deps


Added: gnunet/src/lockmanager/Makefile.am
===================================================================
--- gnunet/src/lockmanager/Makefile.am                          (rev 0)
+++ gnunet/src/lockmanager/Makefile.am  2012-04-26 16:17:49 UTC (rev 21176)
@@ -0,0 +1,38 @@
+INCLUDES = -I$(top_srcdir)/src/include
+
+if MINGW
+  WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+  AM_CFLAGS = --coverage -O0
+  XLIB = -lgcov
+endif
+
+pkgcfgdir= $(pkgdatadir)/config.d/
+
+pkgcfg_DATA = \
+  lockmanager.conf
+
+bin_PROGRAMS = \
+  gnunet-service-lockmanager
+
+lib_LTLIBRARIES = \
+  libgnunetlockmanager.la
+
+gnunet_service_lockmanager_SOURCES = \
+  gnunet-service-lockmanager.c \
+  lockmanager.h
+gnunet_service_lockmanager_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la
+gnunet_service_lockmanager_DEPENDENCIES = \
+  $(top_builddir)/src/util/libgnunetutil.la
+
+libgnunetlockmanager_la_SOURCES = \
+  lockmanager_api.c lockmanager.h
+libgnunetlockmanager_la_LIBADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(XLIB)
+libgnunetlockmanager_la_LDFLAGS = \
+  $(GN_LIB_LDFLAGS) $(WINFLAGS) \
+  -version-info 0:0:0
\ No newline at end of file

Modified: gnunet/src/lockmanager/README
===================================================================
--- gnunet/src/lockmanager/README       2012-04-26 16:13:45 UTC (rev 21175)
+++ gnunet/src/lockmanager/README       2012-04-26 16:17:49 UTC (rev 21176)
@@ -3,8 +3,9 @@
 checks upon a resource which should be protected from concurrent access.
 
 Locking is managed through locking-domains. A locking-domain is a string which
-uniquely identifies a group of locks. Locks are represented as unsigned
+uniquely identifies a group of locks. Locks are represented as unsigned 32-bit
 integers. When a critical resource has to be protected against simulataneous
-access by 2 programs. Both of them should connect to the lockmanager using the
-same locking-domain and try to lock a lock. Since only one of them can acquire
-the lock the other will be denied locking until the other releases it.
\ No newline at end of file
+access by 2 programs, both of them should connect to the lockmanager using the
+same locking-domain and try to acquire a lock with the same number. Since only
+one of them can acquire the lock the other will be denied locking until the
+it the lock is released.
\ No newline at end of file

Added: gnunet/src/lockmanager/gnunet-service-lockmanager.c
===================================================================
--- gnunet/src/lockmanager/gnunet-service-lockmanager.c                         
(rev 0)
+++ gnunet/src/lockmanager/gnunet-service-lockmanager.c 2012-04-26 16:17:49 UTC 
(rev 21176)
@@ -0,0 +1,119 @@
+/*
+     This file is part of GNUnet.
+     (C) 2012 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file lockmanager/gnunet-service-lockmanager.c
+ * @brief implementation of the LOCKMANAGER service
+ * @author Sree Harsha Totakura
+ */
+
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_protocols.h"
+#include "gnunet_service_lib.h"
+#include "gnunet_server_lib.h"
+
+#include "lockmanager.h"
+
+#define LOG(kind,...) \
+  GNUNET_log_from (kind, "gnunet-service-lockmanager",__VA_ARGS__)
+
+
+/**
+ * Handler for GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE
+ *
+ * @param 
+ * @return 
+ */
+static void
+handle_acquire (void *cls,
+                struct GNUNET_SERVER_Client *client,
+                const struct GNUNET_MessageHeader *message)
+{
+  // const struct GNUNET_LOCKMANAGER_Message *msg = message;
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Received a ACQUIRE message\n");
+
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
+ * Handle for GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE
+ *
+ * @param 
+ * @return 
+ */
+static void
+handle_release (void *cls,
+                struct GNUNET_SERVER_Client *client,
+                const struct GNUNET_MessageHeader *message)
+{
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Received a RELEASE message\n");
+
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
+ * Lock manager setup
+ *
+ * @param cls closure
+ * @param server the initialized server
+ * @param cfg configuration to use
+ */
+static void 
+lockmanager_run (void *cls,
+                 struct GNUNET_SERVER_Handle * server,
+                 const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_SERVER_MessageHandler message_handlers[] =
+    {
+      {&handle_acquire, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_ACQUIRE, 0},
+      {&handle_release, NULL, GNUNET_MESSAGE_TYPE_LOCKMANAGER_RELEASE, 0},
+      {NULL}
+    };
+  
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting lockmanager\n");
+  GNUNET_SERVER_add_handlers (server,
+                              message_handlers);
+  
+}
+
+/**
+ * The starting point of execution
+ */
+int main (int argc, char *const *argv)
+{
+  int ret;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "main()\n");
+  ret = 
+    (GNUNET_OK ==
+     GNUNET_SERVICE_run (argc,
+                         argv,
+                         "lockmanager",
+                         GNUNET_SERVICE_OPTION_NONE,
+                         &lockmanager_run,
+                         NULL)) ? 0 : 1;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "main() END\n");
+  return ret;
+}

Added: gnunet/src/lockmanager/lockmanager.conf.in
===================================================================
--- gnunet/src/lockmanager/lockmanager.conf.in                          (rev 0)
+++ gnunet/src/lockmanager/lockmanager.conf.in  2012-04-26 16:17:49 UTC (rev 
21176)
@@ -0,0 +1,13 @@
+[lockmanager]
+AUTOSTART = YES
address@hidden@ PORT = 2100
+HOSTNAME = localhost
+HOME = $SERVICEHOME
+CONFIG = $DEFAULTCONFIG
+BINARY = gnunet-service-lockmanger
+ACCEPT_FROM = 127.0.0.1;
+ACCEPT_FROM6 = ::1;
+UNIXPATH = /tmp/gnunet-service-lockmanager.sock
+UNIX_MATCH_UID = YES
+UNIX_MATCH_GID = YES
+

Added: gnunet/src/lockmanager/lockmanager.h
===================================================================
--- gnunet/src/lockmanager/lockmanager.h                                (rev 0)
+++ gnunet/src/lockmanager/lockmanager.h        2012-04-26 16:17:49 UTC (rev 
21176)
@@ -0,0 +1,71 @@
+/*
+     This file is part of GNUnet.
+     (C) 2012 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file lockmanager/lockmanager.h
+ * @brief client-server protocol messages for LOCKMANAGER service
+ * @author Sree Harsha Totakura
+ */
+
+#ifndef LOCKMANAGER_H
+#define LOCKMANAGER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#if 0                           /* keep Emacsens' auto-indent happy */
+}
+#endif
+#endif
+
+#include "gnunet_common.h"
+
+/**
+ * Structure of Lockmanager message
+ */
+struct GNUNET_LOCKMANAGER_Message
+{
+  /**
+   * The generic message header
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * The lock
+   */
+  uint32_t lock;
+
+  /**
+   * The locking domain name(NULL terminated string of characters) should
+   * follow here. The size of the header should include the size of this string
+   * with its trailing NULL
+   */
+};
+
+#if 0                           /* keep Emacsens' auto-indent happy */
+{
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+/* ifndef LOCKMANAGER_H */
+#endif
+/* end of lockmanager.h */

Added: gnunet/src/lockmanager/lockmanager_api.c
===================================================================
--- gnunet/src/lockmanager/lockmanager_api.c                            (rev 0)
+++ gnunet/src/lockmanager/lockmanager_api.c    2012-04-26 16:17:49 UTC (rev 
21176)
@@ -0,0 +1,80 @@
+/*
+     This file is part of GNUnet.
+     (C) 2012 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file lockmanager/lockmanager_api.c
+ * @brief API implementation of gnunet_lockmanager_service.h
+ * @author Sree Harsha Totakura
+ */
+
+#include "platform.h"
+#include "gnunet_common.h"
+#include "gnunet_protocols.h"
+#include "gnunet_client_lib.h"
+
+#include "lockmanager.h"
+
+#define LOG(kind,...) \
+  GNUNET_log_from (kind, "gnunet-service-lockmanager",__VA_ARGS__)
+
+/**
+ * Handler for the lockmanager service
+ */
+struct GNUNET_LOCKMANAGER_Handle
+{
+  /**
+   * The client connection to the service
+   */
+  struct GNUNET_CLIENT_Connection *conn;
+};
+
+
+/**
+ * Connect to the lockmanager service
+ *
+ * @param cfg the configuration to use
+ *
+ * @return upon success the handle to the service; NULL upon error
+ */
+struct GNUNET_LOCKMANAGER_Handle *
+GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  struct GNUNET_LOCKMANAGER_Handle *h;
+
+  h = GNUNET_malloc (sizeof (struct GNUNET_LOCKMANAGER_Handle));
+  h->conn = GNUNET_CLIENT_connect ("lockmanager", cfg);
+  if (NULL == h->conn)
+    {
+      GNUNET_free (h);
+      return NULL;
+    }
+  return NULL;
+}
+
+/**
+ * Disconnect from the lockmanager service
+ *
+ * @param handle the handle to the lockmanager service
+ */
+void
+GNUNET_LOCKMANAGER_disconnect (struct GNUNET_LOCKMANAGER_Handle *handle)
+{
+  
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]