Univention Bugzilla – Attachment 8123 Details for
Bug 42573
Listener should check free space
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
42573.diff
file_42573.txt (text/plain), 7.93 KB, created by
Philipp Hahn
on 2016-10-17 14:53 CEST
(
hide
)
Description:
42573.diff
Filename:
MIME Type:
Creator:
Philipp Hahn
Created:
2016-10-17 14:53 CEST
Size:
7.93 KB
patch
obsolete
>diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache.c b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache.c >index a4e59e1..d28f96f 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache.c >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache.c >@@ -268,11 +268,11 @@ int cache_set_int(char *key, const NotifierID value) > if (rv < 0 || rv >= PATH_MAX) > return rv; > if ((fp = fopen(tmpfile, "w")) == NULL) >- return 1; >+ abort_io("open", tmpfile); > fprintf(fp, "%ld", value); > rv = fclose(fp); > if (rv != 0) >- return rv; >+ abort_io("close", tmpfile); > > rv = snprintf(file, PATH_MAX, "%s/%s", cache_dir, key); > if (rv < 0 || rv >= PATH_MAX) >@@ -700,7 +700,7 @@ int cache_free_cursor(DBC *cur) > > int cache_close(void) > { >- int rv; >+ int rv = 0; > > if (dbp && (rv = dbp->close(dbp, 0)) != 0) { > dbp->err(dbp, rv, "close"); >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.c b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.c >index f6797e4..38b2d6c 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.c >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.c >@@ -37,6 +37,7 @@ > #include <ctype.h> > #include <stdbool.h> > #include <limits.h> >+#include <errno.h> > #include <sys/types.h> > > #include <univention/debug.h> >@@ -279,10 +280,12 @@ int parse_entry(void *data, u_int32_t size, CacheEntry *entry) > rv = snprintf(filename, PATH_MAX, "%s/bad_cache", cache_dir); > if (rv < 0 || rv >= PATH_MAX) > abort(); >- if ((file = fopen(filename, "w")) != NULL) { >- fprintf(file, "Check log file"); >- fclose(file); >- } >+ if ((file = fopen(filename, "w")) == NULL) >+ abort_io("open", filename); >+ fprintf(file, "Check log file"); >+ rv = fclose(file); >+ if (rv != 0) >+ abort_io("close", filename); > > return -1; > } >@@ -290,3 +293,9 @@ int parse_entry(void *data, u_int32_t size, CacheEntry *entry) > > return 0; > } >+ >+void abort_io(const char *func, const char *filename) >+{ >+ univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "Fatal %s(%s): %s", func, filename, strerror(errno)); >+ abort(); >+} >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.h b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.h >index e19d6d4..55e2ae9 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.h >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/cache_lowlevel.h >@@ -42,5 +42,6 @@ int parse_entry (void *data, > u_int32_t size, > CacheEntry *entry); > void hex_dump(int level, void *data, u_int32_t start, u_int32_t size); >+void abort_io(const char *func, const char *filename) __attribute__((noreturn)); > > #endif /* _CACHE_LOWLEVEL_ */ >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/handlers.c b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/handlers.c >index 7d89581..06c2ab1 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/handlers.c >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/handlers.c >@@ -550,7 +550,9 @@ void handler_write_state(Handler *handler) { > univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not open %s", state_filename); > } else { > fprintf(state_fp, "%d", handler->state); >- fclose(state_fp); >+ rv = fclose(state_fp); >+ if (rv != 0) >+ abort_io("close", state_filename); > } > } > >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/transfile.c b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/transfile.c >index 15459ec..3abb31e 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/transfile.c >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/transfile.c >@@ -92,8 +92,10 @@ static FILE* fopen_lock(const char *name, const char *type, FILE **l_file) > /* Close file and lock file. */ > static int fclose_lock(FILE **file, FILE **l_file) > { >+ int rv = 0; >+ > if (*file != NULL) { >- fclose(*file); >+ rv |= fclose(*file); > *file = NULL; > } > >@@ -102,11 +104,11 @@ static int fclose_lock(FILE **file, FILE **l_file) > int rc = lockf(l_fd, F_ULOCK, 0); > if (rc) > univention_debug(UV_DEBUG_LDAP, UV_DEBUG_ALL, "unlockf(): %d", rc); >- fclose(*l_file); >+ rv |= fclose(*l_file); > *l_file = NULL; > } > >- return 0; >+ return rv; > } > > >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/notifier.c b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/notifier.c >index 5c806cb..cf49f31 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/notifier.c >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/src/notifier.c >@@ -43,8 +43,10 @@ > #include <string.h> > #include <time.h> > #include <sys/time.h> >+#include <sys/statvfs.h> > > #include <univention/debug.h> >+#include <univention/config.h> > #include <univention/ldap.h> > #ifdef WITH_KRB5 > #include <univention/krb5.h> >@@ -84,6 +86,37 @@ static int connect_to_ldap(univention_ldap_parameters_t *lp, > return LDAP_SUCCESS; > } > >+static void check_free_space() >+{ >+ static int min_mib = -2; >+ const char *dirnames[] = { >+ cache_dir, >+ ldap_dir, >+ NULL >+ }, **dirname; >+ >+ if (min_mib == -2) >+ min_mib = univention_config_get_int("listener/freespace"); >+ >+ if (min_mib <= 0) >+ return; >+ >+ for (dirname=dirnames; *dirname; dirname++) { >+ struct statvfs buf; >+ int free_mib; >+ >+ if (statvfs(*dirname, &buf)) >+ continue; >+ >+ free_mib = ((long)buf.f_bavail * (long)buf.f_frsize) >> 20; >+ if (free_mib >= min_mib) >+ continue; >+ >+ univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "File system '%s' full: %d < %d", *dirname, free_mib, min_mib); >+ abort(); >+ } >+} >+ > /* listen for ldap updates */ > int notifier_listen(univention_ldap_parameters_t *lp, > univention_krb5_parameters_t *kp, >@@ -101,6 +134,8 @@ int notifier_listen(univention_ldap_parameters_t *lp, > int msgid; > time_t timeout = DELAY_LDAP_CLOSE; > >+ check_free_space(); >+ > univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "Last Notifier ID: %lu", id); > if ((msgid = notifier_get_dn(NULL, id + 1)) < 1) > break; >diff --git a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables >index d0362d3..574a161 100644 >--- a/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables >+++ b/branches/ucs-4.1/ucs-4.1-3/management/univention-directory-listener/debian/univention-directory-listener.univention-config-registry-variables >@@ -45,3 +45,9 @@ Description[de]=Anzahl der Versuche zum Verbindungsaufbau zum LDAP-Server im Fal > Description[en]=Number of retries to re-connect the LDAP server in case of errors. Default: 5 > Type=int > Categories=service-ln >+ >+[listener/freespace] >+Description[de]=Diese Variable legt die untere Grenze für den freien Speicherplatz in den Verzeichnissen '/var/lib/univention-ldap/' und '/var/lib/univention-directory-listener/', ab der der Listener gestoppt wird. Standard is 10 [MiB]. >+Description[en]=This variable configures the lower limit for free space in the directories '/var/lib/univention-ldap/' and '/var/lib/univention-directory-listener/', when the Listener will be stopped. Default is 10 [MiB]. >+Type=int >+Categories=service-ln
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 42573
: 8123