]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/ringbuf.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / ringbuf.c
index 26c4e744b4973c85c9aac52a1c83a0f022c5516b..3cd7b4987220c94d097d021797cf4600143a48d7 100644 (file)
@@ -1,28 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Circular buffer implementation.
  * Copyright (C) 2017 Cumulus Networks
  * Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <zebra.h>
 
 #include "ringbuf.h"
 #include "memory.h"
 
-DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer")
+DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer");
 
 struct ringbuf *ringbuf_new(size_t size)
 {
@@ -131,38 +118,3 @@ void ringbuf_wipe(struct ringbuf *buf)
        memset(buf->data, 0x00, buf->size);
        ringbuf_reset(buf);
 }
-
-ssize_t ringbuf_read(struct ringbuf *buf, int sock)
-{
-       size_t to_read = ringbuf_space(buf);
-       size_t bytes_to_end = buf->size - buf->end;
-       ssize_t bytes_read;
-       struct iovec iov[2] = {};
-
-       /* Calculate amount of read blocks. */
-       if (to_read > bytes_to_end) {
-               iov[0].iov_base = buf->data + buf->end;
-               iov[0].iov_len = bytes_to_end;
-               iov[1].iov_base = buf->data;
-               iov[1].iov_len = to_read - bytes_to_end;
-       } else {
-               iov[0].iov_base = buf->data + buf->end;
-               iov[0].iov_len = to_read;
-       }
-
-       /* Do the system call. */
-       bytes_read = readv(sock, iov, 2);
-       if (bytes_read <= 0)
-               return bytes_read;
-
-       /* Calculate the new end. */
-       if ((size_t)bytes_read > bytes_to_end)
-               buf->end = bytes_read - bytes_to_end;
-       else
-               buf->end += bytes_read;
-
-       /* Set emptiness state. */
-       buf->empty = (buf->start == buf->end) && (buf->empty && !bytes_read);
-
-       return bytes_read;
-}