Univention Bugzilla – Attachment 7825 Details for
Bug 41842
write handle status after initialization
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Write state after init - compiles but otherwise untested
41842_listener_write_state.diff (text/plain), 7.51 KB, created by
Philipp Hahn
on 2016-07-22 12:42 CEST
(
hide
)
Description:
Write state after init - compiles but otherwise untested
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2016-07-22 12:42 CEST
Size:
7.51 KB
patch
obsolete
>From 9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8 Mon Sep 17 00:00:00 2001 >Message-Id: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 22 Jul 2016 12:25:02 +0200 >Subject: [PATCH 1/4] Bug #41842 listener: Remove unused macros >Organization: Univention GmbH, Bremen, Germany > >Not used anywhere. >--- > .../ucs-4.1-2/management/univention-directory-listener/src/handlers.h | 4 ---- > 1 file changed, 4 deletions(-) > >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >index 0143ef4..bf787ec 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >@@ -50,10 +50,6 @@ > > #define HANDLER_PREPARED 000000004 > >-#define HANDLER_HAS_FLAG(handler, flag) ((handler->state & flag) == flag) >-#define HANDLER_SET_FLAG(handler, flag) handler->state |= flag >-#define HANDLER_UNSET_FLAG(handler, flag) handler->state &= ~flag >- > struct filter { > char *base; > int scope; >-- >2.1.4 > > >From c8b05bb71c4a51b2937eb4bbd797a6b2be5ff741 Mon Sep 17 00:00:00 2001 >Message-Id: <c8b05bb71c4a51b2937eb4bbd797a6b2be5ff741.1469184101.git.hahn@univention.de> >In-Reply-To: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >References: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 22 Jul 2016 12:26:05 +0200 >Subject: [PATCH 2/4] Bug #41842 listener: Convert handler state to enum >Organization: Univention GmbH, Bremen, Germany > >For type safety. >--- > .../management/univention-directory-listener/src/handlers.c | 2 +- > .../management/univention-directory-listener/src/handlers.h | 11 ++++++----- > 2 files changed, 7 insertions(+), 6 deletions(-) > >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >index cd068d1..e063361 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >@@ -262,7 +262,7 @@ static int handler_import(char* filename) > if (state_fp == NULL) { > handler->state = 0; > } else { >- fscanf(state_fp, "%d", &handler->state); >+ fscanf(state_fp, "%u", &handler->state); > fclose(state_fp); > } > >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >index bf787ec..acf5798 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >@@ -45,10 +45,11 @@ > initializing, HANDLER_READY will be set; however, if the > initialization fails, it will be removed again. If it's successful, > both, HANDLER_INITIALIZED and HANDLER_READY will be set */ >-#define HANDLER_INITIALIZED 000000001 >-#define HANDLER_READY 000000002 >- >-#define HANDLER_PREPARED 000000004 >+enum state { >+ HANDLER_INITIALIZED = 1 << 0, >+ HANDLER_READY = 1 << 1, >+ HANDLER_PREPARED = 1 << 2, >+}; > > struct filter { > char *base; >@@ -71,7 +72,7 @@ struct _Handler { > PyObject *setdata; > struct _Handler *next; > >- int state; >+ enum state state; > int prepared : 1; > } typedef Handler; > >-- >2.1.4 > > >From 612b58f4a7fdfa326fe3e3462f6db417b50114b3 Mon Sep 17 00:00:00 2001 >Message-Id: <612b58f4a7fdfa326fe3e3462f6db417b50114b3.1469184101.git.hahn@univention.de> >In-Reply-To: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >References: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 22 Jul 2016 12:27:26 +0200 >Subject: [PATCH 3/4] Bug #41842 listener: Extract code to write handler state >Organization: Univention GmbH, Bremen, Germany > >--- > .../univention-directory-listener/src/handlers.c | 24 ++++++++++++++-------- > .../univention-directory-listener/src/handlers.h | 1 + > 2 files changed, 16 insertions(+), 9 deletions(-) > >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >index e063361..58ea3a0 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.c >@@ -566,19 +566,11 @@ int handlers_load_all_paths(void) > } > > >-/* Free one handler. */ >-int handler_free(Handler *handler) >-{ >- char **a; >- struct filter **f; >+void handler_write_state(Handler *handler) { > char state_filename[PATH_MAX]; > FILE *state_fp; > int rv; > >- if ( handler == NULL || handler->name == NULL ) { >- return 0; >- } >- > /* write handler state */ > /* XXX: can be removed, once we use a database for this */ > rv = snprintf(state_filename, PATH_MAX, "%s/handlers/%s", cache_dir, handler->name); >@@ -591,6 +583,20 @@ int handler_free(Handler *handler) > fprintf(state_fp, "%d", handler->state); > fclose(state_fp); > } >+} >+ >+ >+/* Free one handler. */ >+int handler_free(Handler *handler) >+{ >+ char **a; >+ struct filter **f; >+ >+ if ( handler == NULL || handler->name == NULL ) { >+ return 0; >+ } >+ >+ handler_write_state(handler); > > /* free list node */ > free(handler->name); >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >index acf5798..9039d0f 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/handlers.h >@@ -78,6 +78,7 @@ struct _Handler { > > int handlers_init (void); > int handlers_free_all (void); >+void handler_write_state(Handler *handler); > int handlers_load_path (char *filename); > int handlers_reload_all_paths (void); > int handlers_dump (void); >-- >2.1.4 > > >From a581ea02c5093ca8c3835497db748bd895a4d1a5 Mon Sep 17 00:00:00 2001 >Message-Id: <a581ea02c5093ca8c3835497db748bd895a4d1a5.1469184101.git.hahn@univention.de> >In-Reply-To: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >References: <9ccd1d2ff6ca38e5e42eca91d01f6f08cba052b8.1469184101.git.hahn@univention.de> >From: Philipp Hahn <hahn@univention.de> >Date: Fri, 22 Jul 2016 12:28:19 +0200 >Subject: [PATCH 4/4] Bug #41842 listener: Write handler state after init >Organization: Univention GmbH, Bremen, Germany > >Otherwise only at regular listener shutdown, which might be a long time >away. >--- > .../ucs-4.1-2/management/univention-directory-listener/src/change.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/change.c b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/change.c >index ae1c566..0296d05 100644 >--- a/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/change.c >+++ b/branches/ucs-4.1/ucs-4.1-2/management/univention-directory-listener/src/change.c >@@ -240,6 +240,8 @@ int change_new_modules(univention_ldap_parameters_t *lp) > handler->state |= HANDLER_INITIALIZED; > else > handler->state ^= HANDLER_READY; >+ >+ handler_write_state(handler); > } > } > INIT_ONLY = old_init_only; >-- >2.1.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 41842
:
7825
|
8122