]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
stream: remove lock from StreamTcpSegmentForEach
authorJason Ish <ish@unx.ca>
Wed, 13 Jul 2016 23:07:45 +0000 (17:07 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 19 Sep 2016 11:47:52 +0000 (13:47 +0200)
This is only entered from logging functions which are already
called with a locked flow.

src/stream-tcp.c
src/stream.c

index 72fb4eda9bd062ed5c0f8b11f0b766a9c6a66db9..a0517f3a4b32e110dfa29c03dc59a08b593291ec 100644 (file)
@@ -5723,6 +5723,8 @@ void StreamTcpPseudoPacketCreateStreamEndPacket(ThreadVars *tv, StreamTcpThread
  * \note when stream engine is running in inline mode all segments are used,
  *       in IDS/non-inline mode only ack'd segments are iterated.
  *
+ * \note Must be called under flow lock.
+ *
  * \return -1 in case of error, the number of segment in case of success
  *
  */
@@ -5736,11 +5738,9 @@ int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback
     if (p->flow == NULL)
         return 0;
 
-    FLOWLOCK_RDLOCK(p->flow);
     ssn = (TcpSession *)p->flow->protoctx;
 
     if (ssn == NULL) {
-        FLOWLOCK_UNLOCK(p->flow);
         return 0;
     }
 
@@ -5758,13 +5758,11 @@ int StreamTcpSegmentForEach(const Packet *p, uint8_t flag, StreamSegmentCallback
         ret = CallbackFunc(p, data, seg->payload, seg->payload_len);
         if (ret != 1) {
             SCLogDebug("Callback function has failed");
-            FLOWLOCK_UNLOCK(p->flow);
             return -1;
         }
         seg = seg->next;
         cnt++;
     }
-    FLOWLOCK_UNLOCK(p->flow);
     return cnt;
 }
 
index 8aabd6dcaea6fa2794d9bd3f7dece470d5f1ac48..6415420981a56c2825cce01f11cbbbb2b3920471 100644 (file)
@@ -268,6 +268,8 @@ void StreamMsgReturnListToPool(void *list)
 }
 
 /** \brief Run callback for all segments
+ *
+ * Must be called under flow lock.
  *
  * \return -1 in case of error, the number of segment in case of success
  */