Commit 269342e2 authored by Scott Vokes's avatar Scott Vokes
Browse files

Update tracking of sequence ID monotonicity.

parent c7550d7a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -258,6 +258,16 @@ static boxed_msg *box_msg(struct bus *b, bus_user_msg *msg) {
        box->ssl = ci->ssl;
    }

    if ((msg->seq_id <= ci->largest_wr_seq_id_seen)
            && (ci->largest_wr_seq_id_seen != BUS_NO_SEQ_ID)) {
        BUS_LOG_SNPRINTF(b, 3, LOG_MEMORY, b->udata, 256,
            "rejecting request <fd:%d, seq_id:%lld> due to non-monotonic sequence ID, largest seen is %lld",
            box->fd, (long long)msg->seq_id, (long long)ci->largest_wr_seq_id_seen);
        free(box);
    } else {
        ci->largest_wr_seq_id_seen = msg->seq_id;
    }
    
    box->timeout_sec = (time_t)msg->timeout_sec;
    if (box->timeout_sec == 0) {
        box->timeout_sec = BUS_DEFAULT_TIMEOUT_SEC;
@@ -427,6 +437,8 @@ bool bus_register_socket(struct bus *b, bus_socket_t type, int fd, void *udata)
        .type = type,
        .ssl = ssl,
        .udata = udata,
        .largest_rd_seq_id_seen = BUS_NO_SEQ_ID,
        .largest_wr_seq_id_seen = BUS_NO_SEQ_ID,
    };

    void *old_value = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -234,7 +234,7 @@ typedef enum {
typedef struct {
    int fd;
    bus_socket_t type;
    uint64_t seq_id;
    int64_t seq_id;
    uint8_t *msg;
    size_t msg_size;
    uint16_t timeout_sec;
+3 −2
Original line number Diff line number Diff line
@@ -654,8 +654,9 @@ static void process_unpacked_message(listener *l,
        int64_t seq_id = result.u.success.seq_id;
        void *opaque_msg = result.u.success.msg;

        if (seq_id < ci->largest_rd_seq_id_seen && ci->largest_rd_seq_id_seen != 0
                && seq_id != BUS_NO_SEQ_ID) {
        if ((seq_id < ci->largest_rd_seq_id_seen) &&
                (ci->largest_rd_seq_id_seen != BUS_NO_SEQ_ID) &&
                (seq_id != BUS_NO_SEQ_ID)) {
            BUS_LOG_SNPRINTF(b, 0, LOG_LISTENER, b->udata, 128,
                "suspicious sequence ID on %d: largest seen is %lld, got %lld\n",
                ci->fd, (long long)ci->largest_rd_seq_id_seen, (long long)seq_id);