@@ -70,7 +70,7 @@ class Connection : public util::Connection {
70
70
71
71
// PubSub message, either incoming message for active subscription or reply for new subscription.
72
72
struct PubMessage {
73
- std::string pattern{}; // non-empty for pattern subscriber
73
+ std::string pattern; // non-empty for pattern subscriber
74
74
std::shared_ptr<char []> buf; // stores channel name and message
75
75
std::string_view channel, message; // channel and message parts from buf
76
76
bool should_unsubscribe = false ; // unsubscribe from channel after sending the message
@@ -176,15 +176,16 @@ class Connection : public util::Connection {
176
176
static_assert (sizeof (MessageHandle) <= 80 ,
177
177
" Big structs should use indirection to avoid wasting deque space!" );
178
178
179
- enum Phase { SETUP, READ_SOCKET, PROCESS, SHUTTING_DOWN, PRECLOSE, NUM_PHASES };
179
+ enum Phase : uint8_t { SETUP, READ_SOCKET, PROCESS, SHUTTING_DOWN, PRECLOSE, NUM_PHASES };
180
180
181
181
// Weak reference to a connection, invalidated upon connection close.
182
182
// Used to dispatch async operations for the connection without worrying about pointer lifetime.
183
183
struct WeakRef {
184
184
public:
185
185
// Get residing thread of connection. Thread-safe.
186
- unsigned Thread () const ;
187
-
186
+ unsigned LastKnownThreadId () const {
187
+ return last_known_thread_id_;
188
+ }
188
189
// Get pointer to connection if still valid, nullptr if expired.
189
190
// Can only be called from connection's thread. Validity is guaranteed
190
191
// only until the next suspension point.
@@ -205,7 +206,7 @@ class Connection : public util::Connection {
205
206
WeakRef (std::shared_ptr<Connection> ptr, unsigned thread_id, uint32_t client_id);
206
207
207
208
std::weak_ptr<Connection> ptr_;
208
- unsigned thread_id_ ;
209
+ unsigned last_known_thread_id_ ;
209
210
uint32_t client_id_;
210
211
};
211
212
@@ -288,8 +289,9 @@ class Connection : public util::Connection {
288
289
ConnectionContext* cntx ();
289
290
290
291
// Requests that at some point, this connection will be migrated to `dest` thread.
291
- // Connections will migrate at most once, and only when the flag --migrate_connections is true.
292
- void RequestAsyncMigration (util::fb2::ProactorBase* dest);
292
+ // If force is false, the connection will migrate at most once,
293
+ // and only when the flag --migrate_connections is true.
294
+ void RequestAsyncMigration (util::fb2::ProactorBase* dest, bool force);
293
295
294
296
// Starts traffic logging in the calling thread. Must be a proactor thread.
295
297
// Each thread creates its own log file combining requests from all the connections in
@@ -335,7 +337,7 @@ class Connection : public util::Connection {
335
337
std::unique_ptr<ConnectionContext> cc_; // Null for http connections
336
338
337
339
private:
338
- enum ParserStatus { OK, NEED_MORE, ERROR };
340
+ enum ParserStatus : uint8_t { OK, NEED_MORE, ERROR };
339
341
340
342
struct AsyncOperations ;
341
343
@@ -443,6 +445,7 @@ class Connection : public util::Connection {
443
445
444
446
uint32_t id_;
445
447
Protocol protocol_;
448
+ Phase phase_ = SETUP;
446
449
447
450
struct {
448
451
size_t read_cnt = 0 ; // total number of read calls
@@ -459,7 +462,6 @@ class Connection : public util::Connection {
459
462
ServiceInterface* service_;
460
463
461
464
time_t creation_time_, last_interaction_;
462
- Phase phase_ = SETUP;
463
465
std::string name_;
464
466
465
467
std::string lib_name_;
0 commit comments