Browse Source

fix a bug

Patrick Brosi 4 years ago
parent
commit
06c8a1710a
2 changed files with 20 additions and 8 deletions
  1. 12 4
      src/osmfixer/index/StatIdx.cpp
  2. 8 4
      src/util/http/Server.cpp

+ 12 - 4
src/osmfixer/index/StatIdx.cpp

@@ -297,14 +297,22 @@ void StatIdx::initGroups() {
297
       _groups[_stations[i].origGroup].stations.push_back(i);
297
       _groups[_stations[i].origGroup].stations.push_back(i);
298
     }
298
     }
299
 
299
 
300
-    if (_stations[i].group != _stations[i].origGroup &&
301
-        _groups[_stations[i].group].osmid > 2 &&
300
+    // if all stations of a relation are moved into another same relation,
301
+    // suggest to merge the relation instead of suggesting each invidivual
302
+    // move
303
+    if (_groups[_stations[i].group].osmid > 2 &&
302
         _groups[_stations[i].origGroup].osmid > 2) {
304
         _groups[_stations[i].origGroup].osmid > 2) {
303
       auto& orGr = _groups[_stations[i].origGroup];
305
       auto& orGr = _groups[_stations[i].origGroup];
304
-      if (orGr.mergeId == 0)
306
+      if (orGr.mergeId == 0) {
307
+        // if no merge group has been yet written, set it to the target group
308
+        // of the currently check station
305
         orGr.mergeId = _stations[i].group;
309
         orGr.mergeId = _stations[i].group;
306
-      else if (orGr.mergeId != _stations[i].group)
310
+      } else if (orGr.mergeId != _stations[i].group) {
311
+        // if a merge group was set, but the current station is not moved into
312
+        // this group, set the merge id to the group id. This is later inter-
313
+        // preted as DO NOT MERGE
307
         orGr.mergeId = orGr.id;
314
         orGr.mergeId = orGr.id;
315
+      }
308
     }
316
     }
309
 
317
 
310
     assert(_stations[i].group < _groups.size());
318
     assert(_stations[i].group < _groups.size());

+ 8 - 4
src/util/http/Server.cpp

@@ -11,6 +11,7 @@
11
 #include <netinet/in.h>
11
 #include <netinet/in.h>
12
 #include <netinet/tcp.h>
12
 #include <netinet/tcp.h>
13
 #include <algorithm>
13
 #include <algorithm>
14
+#include <csignal>
14
 #include <memory>
15
 #include <memory>
15
 #include <sstream>
16
 #include <sstream>
16
 #include <stdexcept>
17
 #include <stdexcept>
@@ -24,12 +25,12 @@
24
 #include "util/String.h"
25
 #include "util/String.h"
25
 #include "util/log/Log.h"
26
 #include "util/log/Log.h"
26
 
27
 
27
-using util::http::Socket;
28
-using util::http::Queue;
29
-using util::http::Req;
28
+using util::http::HeaderState;
30
 using util::http::HttpErr;
29
 using util::http::HttpErr;
31
 using util::http::HttpServer;
30
 using util::http::HttpServer;
32
-using util::http::HeaderState;
31
+using util::http::Queue;
32
+using util::http::Req;
33
+using util::http::Socket;
33
 
34
 
34
 // _____________________________________________________________________________
35
 // _____________________________________________________________________________
35
 Socket::Socket(int port) {
36
 Socket::Socket(int port) {
@@ -71,6 +72,9 @@ int Socket::wait() {
71
 
72
 
72
 // _____________________________________________________________________________
73
 // _____________________________________________________________________________
73
 void HttpServer::send(int sock, Answer* aw) {
74
 void HttpServer::send(int sock, Answer* aw) {
75
+  // ignore SIGPIPE
76
+  signal(SIGPIPE, SIG_IGN);
77
+
74
   std::string enc = "identity";
78
   std::string enc = "identity";
75
   if (aw->gzip) aw->pl = compress(aw->pl, &enc);
79
   if (aw->gzip) aw->pl = compress(aw->pl, &enc);
76
 
80