File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ void PubSubThread::Subscribe(PinkConn *conn,
147147 const bool pattern,
148148 std::vector<std::pair<std::string, int >>* result) {
149149 int subscribed = ClientChannelSize (conn);
150+ bool exist = (subscribed != 0 );
150151
151152 for (size_t i = 0 ; i < channels.size (); i++) {
152153 if (pattern) { // if pattern mode, register channel to map
@@ -184,15 +185,17 @@ void PubSubThread::Subscribe(PinkConn *conn,
184185 }
185186 }
186187
187- {
188- slash::WriteLock l (&rwlock_);
189- conns_[conn->fd ()] = conn;
190- }
188+ if (!exist) {
189+ {
190+ slash::WriteLock l (&rwlock_);
191+ conns_[conn->fd ()] = conn;
192+ }
191193
192- {
193- slash::MutexLock l (&mutex_);
194- fd_queue_.push (conn->fd ());
195- write (notify_pfd_[1 ], " " , 1 );
194+ {
195+ slash::MutexLock l (&mutex_);
196+ fd_queue_.push (conn->fd ());
197+ write (notify_pfd_[1 ], " " , 1 );
198+ }
196199 }
197200}
198201
You can’t perform that action at this time.
0 commit comments