Commit c21d9594 authored by Marc-André Lureau's avatar Marc-André Lureau Committed by Samuel Thibault
Browse files

slirp: replace qemu_notify_event() with a callback



Introduce a SlirpCb callback to kick the main io-thread.

Add an intermediary sodrop() function that will call SlirpCb.notify
callback when sbdrop() returns true.

Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
parent f6e5aa36
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ static const SlirpCb slirp_cb = {
    .timer_mod = net_slirp_timer_mod,
    .register_poll_fd = net_slirp_register_poll_fd,
    .unregister_poll_fd = net_slirp_unregister_poll_fd,
    .notify = qemu_notify_event,
};

static int net_slirp_init(NetClientState *peer, const char *model,
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ typedef struct SlirpCb {
    void (*register_poll_fd)(int fd);
    /* Unregister a fd */
    void (*unregister_poll_fd)(int fd);
    /* Kick the io-thread, to signal that new events may be processed */
    void (*notify)(void);
} SlirpCb;


+4 −2
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ sbfree(struct sbuf *sb)
	free(sb->sb_data);
}

void
bool
sbdrop(struct sbuf *sb, int num)
{
    int limit = sb->sb_datalen / 2;
@@ -34,8 +34,10 @@ sbdrop(struct sbuf *sb, int num)
		sb->sb_rptr -= sb->sb_datalen;

    if (sb->sb_cc < limit && sb->sb_cc + num >= limit) {
        qemu_notify_event();
        return true;
    }

    return false;
}

void
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ struct sbuf {
};

void sbfree(struct sbuf *);
void sbdrop(struct sbuf *, int);
bool sbdrop(struct sbuf *, int);
void sbreserve(struct sbuf *, int);
void sbappend(struct socket *, struct mbuf *);
void sbcopy(struct sbuf *, int, int, char *);
+7 −0
Original line number Diff line number Diff line
@@ -928,3 +928,10 @@ void sotranslate_accept(struct socket *so)
        break;
    }
}

void sodrop(struct socket *s, int num)
{
    if (sbdrop(&s->so_snd, num)) {
        s->slirp->cb->notify();
    }
}
Loading