Browse Source

Merge pull request #1477 from cdjingit/typo_fix

typo fix
LorinLee 2 năm trước cách đây
mục cha
commit
950c8c3d94
2 tập tin đã thay đổi với 31 bổ sung32 xóa
  1. 21 22
      src/brpc/socket.h
  2. 10 10
      src/brpc/span.cpp

+ 21 - 22
src/brpc/socket.h

@@ -164,7 +164,7 @@ struct PipelinedInfo {
 struct SocketSSLContext {
     SocketSSLContext();
     ~SocketSSLContext();
-    
+
     SSL_CTX* raw_ctx;           // owned
     std::string sni_name;       // useful for clients
 };
@@ -174,7 +174,7 @@ struct SocketOptions {
     SocketOptions();
 
     // If `fd' is non-negative, set `fd' to be non-blocking and take the
-    // ownership. Socket will close the fd(if needed) and call 
+    // ownership. Socket will close the fd(if needed) and call
     // user->BeforeRecycle() before recycling.
     int fd;
     butil::EndPoint remote_side;
@@ -230,7 +230,7 @@ public:
     // message is written once directly in the calling thread. If the message
     // is not completely written, a KeepWrite thread is created to continue
     // the writing. When other threads want to write simultaneously (thread
-    // contention), they append WriteRequests to the KeepWrite thread in a 
+    // contention), they append WriteRequests to the KeepWrite thread in a
     // wait-free manner rather than writing to the file descriptor directly.
     // KeepWrite will not quit until all WriteRequests are complete.
     // Key properties:
@@ -247,7 +247,7 @@ public:
         // remote_side() regarding deadline `abstime'. NULL means no timeout.
         // Default: NULL
         const timespec* abstime;
-        
+
         // Will be queued to implement positional correspondence with responses
         // Default: 0
         uint32_t pipelined_count;
@@ -257,7 +257,7 @@ public:
         // responded by the server and processed specially when dealing
         // with the response.
         bool with_auth;
-        
+
         // Do not return EOVERCROWDED
         // Default: false
         bool ignore_eovercrowded;
@@ -268,7 +268,7 @@ public:
             , ignore_eovercrowded(false) {}
     };
     int Write(butil::IOBuf *msg, const WriteOptions* options = NULL);
-    
+
     // Write an user-defined message. `msg' is released when Write() is
     // successful and *may* remain unchanged otherwise.
     int Write(SocketMessagePtr<>& msg, const WriteOptions* options = NULL);
@@ -319,7 +319,7 @@ public:
     // Place the Socket associated with identifier `id' into unique_ptr `ptr',
     // which will be released automatically when out of scope (w/o explicit
     // std::move). User can still access `ptr' after calling ptr->SetFailed()
-    // before release of `ptr'. 
+    // before release of `ptr'.
     // This function is wait-free.
     // Returns 0 on success, -1 when the Socket was SetFailed().
     static int Address(SocketId id, SocketUniquePtr* ptr);
@@ -419,7 +419,7 @@ public:
 
     void set_preferred_index(int index) { _preferred_index = index; }
     int preferred_index() const { return _preferred_index; }
-    
+
     void set_type_of_service(int tos) { _tos = tos; }
 
     // Call this method every second (roughly)
@@ -435,11 +435,11 @@ public:
     // Postpone EOF event until `CheckEOF' has been called
     void PostponeEOF();
     void CheckEOF();
-    
+
     SSLState ssl_state() const { return _ssl_state; }
     bool is_ssl() const { return ssl_state() == SSL_CONNECTED; }
     X509* GetPeerCertificate() const;
-    
+
     // Print debugging inforamtion of `id' into the ostream.
     static void DebugSocket(std::ostream&, SocketId id);
 
@@ -550,7 +550,7 @@ friend void DereferenceSocket(Socket*);
     // SSLState is SSL_UNKNOWN, try to detect at first), read data
     // using the corresponding method into `_read_buf'. Returns read
     // bytes on success, 0 on EOF, -1 otherwise and errno is set
-    ssize_t DoRead(size_t size_hint);  
+    ssize_t DoRead(size_t size_hint);
 
     // Based upon whether the underlying channel is using SSL, write
     // `req' using the corresponding method. Returns written bytes on
@@ -583,7 +583,7 @@ friend void DereferenceSocket(Socket*);
     //   1  - Trying to establish connection
     //   -1 - Failed to connect to remote side
     int ConnectIfNot(const timespec* abstime, WriteRequest* req);
-    
+
     int ResetFileDescriptor(int fd);
 
     // Wait until nref hits `expected_nref' and reset some internal resources.
@@ -649,7 +649,7 @@ friend void DereferenceSocket(Socket*);
     SharedPart* GetOrNewSharedPartSlower();
 
     void CheckEOFInternal();
-    
+
     // _error_code is set after a socket becomes failed, during the time
     // gap, _error_code is 0. The race condition is by-design and acceptable.
     // To always get a non-zero error_code, readers should call this method
@@ -680,15 +680,14 @@ private:
 
     // [ Set in dispatcher ]
     // To keep the callback in at most one bthread at any time. Read comments
-    // of EventDispatcher::ProcessEvent in event_dispatcher.cpp to
-    // understand the tricks.
+    // about ProcessEvent in socket.cpp to understand the tricks.
     butil::atomic<int> _nevent;
 
     // May be set by Acceptor to share keytables between reading threads
     // on sockets created by the Acceptor.
     bthread_keytable_pool_t* _keytable_pool;
-    
-    // [ Set in ResetFileDescriptor ] 
+
+    // [ Set in ResetFileDescriptor ]
     butil::atomic<int> _fd;  // -1 when not connected.
     int _tos;                // Type of service which is actually only 8bits.
     int64_t _reset_fd_real_us; // When _fd was reset, in microseconds.
@@ -698,7 +697,7 @@ private:
 
     // Address of self. Initialized in ResetFileDescriptor().
     butil::EndPoint _local_side;
-        
+
     // Called when edge-triggered events happened on `_fd'. Read comments
     // of EventDispatcher::AddConsumer (event_dispatcher.h)
     // carefully before implementing the callback.
@@ -717,7 +716,7 @@ private:
 
     // Identifier of this Socket in ResourcePool
     SocketId _this_id;
-    
+
     // last chosen index of the protocol as a heuristic value to avoid
     // iterating all protocol handlers each time.
     int _preferred_index;
@@ -754,8 +753,8 @@ private:
     // 1-bit flag to ensure `SetEOF' to be called only once
     // 31-bit counter of requests that are currently being processed
     butil::atomic<uint32_t> _ninprocess;
-    
-    // +---32 bit---+---32 bit---+ 
+
+    // +---32 bit---+---32 bit---+
     // |  auth flag | auth error |
     // +------------+------------+
     // Meanings of `auth flag':
@@ -808,7 +807,7 @@ private:
     butil::atomic<int64_t> _last_writetime_us;
     // Queued but written
     butil::atomic<int64_t> _unwritten_bytes;
-    
+
     // Butex to wait for EPOLLOUT event
     butil::atomic<int>* _epollout_butex;
 

+ 10 - 10
src/brpc/span.cpp

@@ -81,7 +81,7 @@ inline uint64_t UpdateTLSRandom64(IdGen* g) {
 
 inline uint64_t GenerateSpanId() {
     // 0 is an invalid Id
-    IdGen* g = &tls_trace_id_gen;
+    IdGen* g = &tls_span_id_gen;
     if (g->seq == 0) {
         UpdateTLSRandom64(g);
         g->seq = 1;
@@ -91,7 +91,7 @@ inline uint64_t GenerateSpanId() {
 
 inline uint64_t GenerateTraceId() {
     // 0 is an invalid Id
-    IdGen* g = &tls_span_id_gen;
+    IdGen* g = &tls_trace_id_gen;
     if (g->seq == 0) {
         UpdateTLSRandom64(g);
         g->seq = 1;
@@ -294,7 +294,7 @@ bool SpanInfoExtractor::PopAnnotation(
 bool CanAnnotateSpan() {
     return bthread::tls_bls.rpcz_parent_span;
 }
-    
+
 void AnnotateSpan(const char* fmt, ...) {
     Span* span = (Span*)bthread::tls_bls.rpcz_parent_span;
     va_list ap;
@@ -322,7 +322,7 @@ private:
         std::swap(db1.time_db, db2.time_db);
         std::swap(db1.time_db_name, db2.time_db_name);
     }
-    
+
     ~SpanDB() {
         if (id_db == NULL && time_db == NULL) {
             return;
@@ -363,7 +363,7 @@ public:
     void process(std::vector<bvar::Collected*> & list) {
         // Sort spans by their starting time so that the code on making
         // time monotonic in Span::Index works better.
-        std::sort(list.begin(), list.end(), SpanEarlier()); 
+        std::sort(list.begin(), list.end(), SpanEarlier());
     }
 };
 static SpanPreprocessor* g_span_prep = NULL;
@@ -514,7 +514,7 @@ leveldb::Status SpanDB::Index(const Span* span, std::string* value_buf) {
     options.sync = false;
 
     leveldb::Status st;
-    
+
     // NOTE: Writing into time_db before id_db so that if the second write
     // fails, the entry in time_db will be finally removed when it's out
     // of time window.
@@ -564,7 +564,7 @@ leveldb::Status SpanDB::Index(const Span* span, std::string* value_buf) {
     if (!st.ok()) {
         return st;
     }
-    
+
     uint32_t key_data[4];
     ToBigEndian(span->trace_id(), key_data);
     ToBigEndian(span->span_id(), key_data + 2);
@@ -603,7 +603,7 @@ leveldb::Status SpanDB::RemoveSpansBefore(int64_t tm) {
             LOG(ERROR) << "Invalid key size: " << it->key().size();
             continue;
         }
-        const int64_t realtime = 
+        const int64_t realtime =
             ToLittleEndian((const uint32_t*)it->key().data());
         if (realtime >= tm) {  // removal is done.
             break;
@@ -635,7 +635,7 @@ leveldb::Status SpanDB::RemoveSpansBefore(int64_t tm) {
 // Write span into leveldb.
 void Span::dump_and_destroy(size_t /*round*/) {
     StartIndexingIfNeeded();
-    
+
     std::string value_buf;
 
     butil::intrusive_ptr<SpanDB> db;
@@ -776,7 +776,7 @@ void DescribeSpanDB(std::ostream& os) {
     if (GetSpanDB(&db) != 0) {
         return;
     }
-    
+
     if (db->id_db != NULL) {
         std::string val;
         if (db->id_db->GetProperty(leveldb::Slice("leveldb.stats"), &val)) {