commit 5c420a813d66f7a90375a80954e11eb7945ebb6c from: Omar Polo date: Fri Jul 30 14:16:02 2021 UTC don't allow multiple attach and log commit - 4fa53a98ae6a42ada0b4d4b5516b7eb84e67ba6b commit + 5c420a813d66f7a90375a80954e11eb7945ebb6c blob - 601ae0b31aa6b6b4def0c5e61370662b1719ca54 blob + a7796b2dc55580cd77bc2da5b8a18c7728877970 --- client.c +++ client.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -64,7 +65,7 @@ static struct imsgev *iev_listener; static struct evbuffer *evb; static uint32_t peerid; -static int handshaked; +static int handshaked, attached; uint32_t msize; static ATTR_DEAD void client_shutdown(void); @@ -536,6 +537,11 @@ handle_message(struct imsg *imsg, size_t len) break; case Tattach: + if (attached) { + np_error(hdr.tag, "already attached"); + return; + } + /* fid[4] afid[4] uname[s] aname[s] */ /* for the moment, happily ignore afid */ @@ -562,7 +568,10 @@ handle_message(struct imsg *imsg, size_t len) return; } + log_debug("qid{path=%"PRIu64" vers=%d type=0x%x}", + qid->path, qid->vers, qid->type); np_attach(hdr.tag, qid); + attached = 1; break;