Skip to content
This repository
Browse code

Merged git://github.com/Justasic/mineserver.git and fixed windows issues

  • Loading branch information...
commit 6e4a8ea069a46e592aab62d3c830b44db158d41e 1 parent a6ac3e4
Marko Viitanen authored June 07, 2012
0  include/Signal.h → include/signalhandler.h
File renamed without changes
7  src/mineserver.cpp
@@ -41,7 +41,7 @@
41 41
 #include <fstream>
42 42
 
43 43
 #include "mineserver.h"
44  
-#include "Signal.h"
  44
+#include "signalhandler.h"
45 45
 #include "configure.h"
46 46
 #include "constants.h"
47 47
 #include "logger.h"
@@ -722,8 +722,11 @@ bool Mineserver::run()
722 722
       }
723 723
     }
724 724
   }
725  
-
  725
+  #ifdef WIN32
  726
+  closesocket(m_socketlisten);
  727
+  #else
726 728
   close(m_socketlisten);
  729
+  #endif
727 730
 
728 731
   saveAll();
729 732
 
25  src/signal.cpp → src/signalhandler.cpp
@@ -25,7 +25,7 @@
25 25
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 26
 */
27 27
 
28  
-#include "Signal.h"
  28
+#include "signalhandler.h"
29 29
 #include "mineserver.h"
30 30
 #include "constants.h"
31 31
 #include "logger.h"
@@ -38,7 +38,7 @@
38 38
 #include <ctime>
39 39
 #include <signal.h>
40 40
 
41  
-#ifndef SIGBREK
  41
+#ifndef SIGBREAK
42 42
 # define SIGBREAK 0 // Define this for unix systems
43 43
 #endif
44 44
 char segv_location[255];
@@ -48,9 +48,11 @@ void SignalHandler(int);
48 48
 void InitSignals()
49 49
 {
50 50
   signal(SIGTERM, SignalHandler); // Justasic: Terminate signal sent by kill
  51
+  #ifndef WIN32
51 52
   signal(SIGKILL, SignalHandler); // Justasic: Kill signal sent by kill or kernel i think
52  
-  signal(SIGINT, SignalHandler);  // Justasic: Signal Interrupt, usually a CTRL+C at console
53 53
   signal(SIGHUP, SignalHandler);  // Justasic: Signal Hangup, typically used as a Config Rehash
  54
+  #endif
  55
+  signal(SIGINT, SignalHandler);  // Justasic: Signal Interrupt, usually a CTRL+C at console
54 56
   signal(SIGBREAK, SignalHandler); // Justasic: ?? is this like sigterm?
55 57
   #ifdef HAVE_BACKTRACE
56 58
   signal(SIGSEGV, SignalHandler); // Justasic: Segmentation Fault signal, used for generating segfault reports
@@ -110,11 +112,7 @@ void SignalHandler(int sig)
110 112
 {
111 113
   switch(sig)
112 114
   {
113  
-    case SIGHUP:
114  
-      signal(sig, SIG_IGN);
115  
-      /* TODO: Rehash a config? hmmnn */
116  
-      LOG2(INFO, "Received SIGHUP, rehashing..");
117  
-      break;
  115
+
118 116
 #ifdef HAVE_BACKTRACE
119 117
     case SIGSEGV:
120 118
       // Justasic: You can stop SIGSEGV's but I HIGHLY recommend against it unless you have good reason to.
@@ -122,16 +120,25 @@ void SignalHandler(int sig)
122 120
       HandleSegfault();
123 121
       break;
124 122
 #endif
  123
+    #ifndef WIN32
  124
+    case SIGHUP:
  125
+      signal(sig, SIG_IGN);
  126
+      /* TODO: Rehash a config? hmmnn */
  127
+      LOG2(INFO, "Received SIGHUP, rehashing..");
  128
+      break;
125 129
     case SIGPIPE:
126 130
       // Justasic: Ignore sigpipe since it just gets in the way.
127 131
       signal(sig, SIG_IGN);
128 132
       break;
129  
-    case SIGINT:
130 133
     case SIGKILL:
  134
+    #endif
  135
+    case SIGINT:    
131 136
     case SIGBREAK:
132 137
     case SIGTERM:
133 138
       signal(sig, SIG_IGN);
  139
+      #ifndef WIN32
134 140
       signal(SIGHUP, SIG_IGN);
  141
+      #endif
135 142
       LOG2(INFO, "Received SIGTERM, Exiting..");
136 143
       Mineserver::get()->stop();
137 144
       break;

0 notes on commit 6e4a8ea

Please sign in to comment.
Something went wrong with that request. Please try again.