Permalink
Browse files

Don't fail if a tun device can not be configured.

  • Loading branch information...
1 parent 347b680 commit c90f624bb0c0a8aaa4e9a20e3c9c9bf4f3e8d94a Caleb James DeLisle committed Jun 20, 2012
Showing with 20 additions and 15 deletions.
  1. +8 −3 cjdroute.c
  2. +10 −7 exception/Except.h
  3. +2 −5 exception/ExceptionHandler.h
View
@@ -25,6 +25,7 @@
#include "dht/dhtcore/RouterModule_admin.h"
#include "exception/ExceptionHandler.h"
#include "exception/AbortHandler.h"
+#include "exception/Jmp.h"
#include "interface/Interface.h"
#include "interface/TUNInterface.h"
#include "interface/TUNConfigurator.h"
@@ -322,9 +323,13 @@ static void registerRouter(Dict* config, struct Address* addr, struct Context* c
assignedTunName,
context->logger,
AbortHandler_INSTANCE);
-
- TUNConfigurator_setIpAddress(
- assignedTunName, addr->ip6.bytes, 8, context->logger, AbortHandler_INSTANCE);
+ struct Jmp jmp;
+ Jmp_try(jmp) {
+ TUNConfigurator_setIpAddress(
+ assignedTunName, addr->ip6.bytes, 8, context->logger, &jmp.handler);
+ } Jmp_catch {
+ Log_warn(context->logger, "Unable to configure ip address [%s]", jmp.message);
+ }
struct TUNInterface* tun = TUNInterface_new(tunPtr, context->base, context->allocator);
context->tunInterface = TUNInterface_asGeneric(tun);
View
@@ -15,28 +15,31 @@
#ifndef Except_H
#define Except_H
-#include "exception/ExceptionHandler.h"
#include "util/Gcc.h"
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#define Except ExceptionHandler
+#define Except_BUFFER_SZ 1024
+
+struct Except
+{
+ void (* exception)(char* message, int code, struct Except* handler);
+
+ char message[Except_BUFFER_SZ];
+};
Gcc_NORETURN
Gcc_PRINTF(3, 4)
static inline void Except_raise(struct Except* eh, int code, char* format, ...)
{
- #define Except_BUFFER_SZ 1024
- char buff[Except_BUFFER_SZ];
-
va_list args;
va_start(args, format);
- vsnprintf(buff, Except_BUFFER_SZ, format, args);
+ vsnprintf(eh->message, Except_BUFFER_SZ, format, args);
- eh->exception(buff, code, eh);
+ eh->exception(eh->message, code, eh);
abort();
}
@@ -15,11 +15,8 @@
#ifndef ExceptionHandler_H
#define ExceptionHandler_H
-struct ExceptionHandler
-{
- void (* exception)(char* message, int code, struct ExceptionHandler* handler);
+#include "exception/Except.h"
- void* context;
-};
+#define ExceptionHandler Except
#endif

0 comments on commit c90f624

Please sign in to comment.