diff options
Diffstat (limited to 'linden/indra/llmessage/llcachename.cpp')
-rw-r--r-- | linden/indra/llmessage/llcachename.cpp | 196 |
1 files changed, 97 insertions, 99 deletions
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp index 2a21b5a..d960429 100644 --- a/linden/indra/llmessage/llcachename.cpp +++ b/linden/indra/llmessage/llcachename.cpp | |||
@@ -66,132 +66,130 @@ LLCacheName* gCacheName = NULL; | |||
66 | /// class LLCacheNameEntry | 66 | /// class LLCacheNameEntry |
67 | /// --------------------------------------------------------------------------- | 67 | /// --------------------------------------------------------------------------- |
68 | 68 | ||
69 | namespace { | 69 | class LLCacheNameEntry |
70 | class LLCacheNameEntry | 70 | { |
71 | { | 71 | public: |
72 | public: | 72 | LLCacheNameEntry(); |
73 | LLCacheNameEntry(); | ||
74 | 73 | ||
75 | public: | 74 | public: |
76 | bool mIsGroup; | 75 | bool mIsGroup; |
77 | U32 mCreateTime; // unix time_t | 76 | U32 mCreateTime; // unix time_t |
78 | char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 77 | char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ |
79 | char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 78 | char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ |
80 | char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ | 79 | char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ |
81 | }; | 80 | }; |
82 | 81 | ||
83 | LLCacheNameEntry::LLCacheNameEntry() | 82 | LLCacheNameEntry::LLCacheNameEntry() |
84 | { | 83 | { |
85 | mFirstName[0] = '\0'; | 84 | mFirstName[0] = '\0'; |
86 | mLastName[0] = '\0'; | 85 | mLastName[0] = '\0'; |
87 | mGroupName[0] = '\0'; | 86 | mGroupName[0] = '\0'; |
88 | } | 87 | } |
89 | 88 | ||
90 | 89 | ||
91 | class PendingReply | 90 | class PendingReply |
92 | { | 91 | { |
93 | public: | 92 | public: |
94 | LLUUID mID; | 93 | LLUUID mID; |
95 | LLCacheNameCallback mCallback; | 94 | LLCacheNameCallback mCallback; |
96 | LLHost mHost; | 95 | LLHost mHost; |
97 | void* mData; | 96 | void* mData; |
98 | PendingReply(const LLUUID& id, LLCacheNameCallback callback, void* data = NULL) | 97 | PendingReply(const LLUUID& id, LLCacheNameCallback callback, void* data = NULL) |
99 | : mID(id), mCallback(callback), mData(data) | 98 | : mID(id), mCallback(callback), mData(data) |
100 | { } | 99 | { } |
101 | 100 | ||
102 | PendingReply(const LLUUID& id, const LLHost& host) | 101 | PendingReply(const LLUUID& id, const LLHost& host) |
103 | : mID(id), mCallback(0), mHost(host) | 102 | : mID(id), mCallback(0), mHost(host) |
104 | { } | 103 | { } |
105 | 104 | ||
106 | void done() { mID.setNull(); } | 105 | void done() { mID.setNull(); } |
107 | bool isDone() const { return mID.isNull() != FALSE; } | 106 | bool isDone() const { return mID.isNull() != FALSE; } |
108 | }; | 107 | }; |
109 | 108 | ||
110 | class ReplySender | 109 | class ReplySender |
111 | { | 110 | { |
112 | public: | 111 | public: |
113 | ReplySender(LLMessageSystem* msg); | 112 | ReplySender(LLMessageSystem* msg); |
114 | ~ReplySender(); | 113 | ~ReplySender(); |
115 | 114 | ||
116 | void send(const LLUUID& id, | 115 | void send(const LLUUID& id, |
117 | const LLCacheNameEntry& entry, const LLHost& host); | 116 | const LLCacheNameEntry& entry, const LLHost& host); |
118 | 117 | ||
119 | private: | 118 | private: |
120 | void flush(); | 119 | void flush(); |
121 | 120 | ||
122 | LLMessageSystem* mMsg; | 121 | LLMessageSystem* mMsg; |
123 | bool mPending; | 122 | bool mPending; |
124 | bool mCurrIsGroup; | 123 | bool mCurrIsGroup; |
125 | LLHost mCurrHost; | 124 | LLHost mCurrHost; |
126 | }; | 125 | }; |
127 | 126 | ||
128 | ReplySender::ReplySender(LLMessageSystem* msg) | 127 | ReplySender::ReplySender(LLMessageSystem* msg) |
129 | : mMsg(msg), mPending(false) | 128 | : mMsg(msg), mPending(false) |
130 | { } | 129 | { } |
131 | 130 | ||
132 | ReplySender::~ReplySender() | 131 | ReplySender::~ReplySender() |
133 | { | 132 | { |
134 | flush(); | 133 | flush(); |
135 | } | 134 | } |
136 | 135 | ||
137 | void ReplySender::send(const LLUUID& id, | 136 | void ReplySender::send(const LLUUID& id, |
138 | const LLCacheNameEntry& entry, const LLHost& host) | 137 | const LLCacheNameEntry& entry, const LLHost& host) |
138 | { | ||
139 | if (mPending) | ||
139 | { | 140 | { |
140 | if (mPending) | 141 | if (mCurrIsGroup != entry.mIsGroup |
142 | || mCurrHost != host) | ||
141 | { | 143 | { |
142 | if (mCurrIsGroup != entry.mIsGroup | 144 | flush(); |
143 | || mCurrHost != host) | ||
144 | { | ||
145 | flush(); | ||
146 | } | ||
147 | } | 145 | } |
146 | } | ||
148 | 147 | ||
149 | if (!mPending) | 148 | if (!mPending) |
150 | { | 149 | { |
151 | mPending = true; | 150 | mPending = true; |
152 | mCurrIsGroup = entry.mIsGroup; | 151 | mCurrIsGroup = entry.mIsGroup; |
153 | mCurrHost = host; | 152 | mCurrHost = host; |
154 | |||
155 | if(mCurrIsGroup) | ||
156 | mMsg->newMessageFast(_PREHASH_UUIDGroupNameReply); | ||
157 | else | ||
158 | mMsg->newMessageFast(_PREHASH_UUIDNameReply); | ||
159 | } | ||
160 | 153 | ||
161 | mMsg->nextBlockFast(_PREHASH_UUIDNameBlock); | ||
162 | mMsg->addUUIDFast(_PREHASH_ID, id); | ||
163 | if(mCurrIsGroup) | 154 | if(mCurrIsGroup) |
164 | { | 155 | mMsg->newMessageFast(_PREHASH_UUIDGroupNameReply); |
165 | mMsg->addStringFast(_PREHASH_GroupName, entry.mGroupName); | ||
166 | } | ||
167 | else | 156 | else |
168 | { | 157 | mMsg->newMessageFast(_PREHASH_UUIDNameReply); |
169 | mMsg->addStringFast(_PREHASH_FirstName, entry.mFirstName); | 158 | } |
170 | mMsg->addStringFast(_PREHASH_LastName, entry.mLastName); | ||
171 | } | ||
172 | 159 | ||
173 | if(mMsg->isSendFullFast(_PREHASH_UUIDNameBlock)) | 160 | mMsg->nextBlockFast(_PREHASH_UUIDNameBlock); |
174 | { | 161 | mMsg->addUUIDFast(_PREHASH_ID, id); |
175 | flush(); | 162 | if(mCurrIsGroup) |
176 | } | 163 | { |
164 | mMsg->addStringFast(_PREHASH_GroupName, entry.mGroupName); | ||
165 | } | ||
166 | else | ||
167 | { | ||
168 | mMsg->addStringFast(_PREHASH_FirstName, entry.mFirstName); | ||
169 | mMsg->addStringFast(_PREHASH_LastName, entry.mLastName); | ||
177 | } | 170 | } |
178 | 171 | ||
179 | void ReplySender::flush() | 172 | if(mMsg->isSendFullFast(_PREHASH_UUIDNameBlock)) |
180 | { | 173 | { |
181 | if (mPending) | 174 | flush(); |
182 | { | ||
183 | mMsg->sendReliable(mCurrHost); | ||
184 | mPending = false; | ||
185 | } | ||
186 | } | 175 | } |
176 | } | ||
187 | 177 | ||
178 | void ReplySender::flush() | ||
179 | { | ||
180 | if (mPending) | ||
181 | { | ||
182 | mMsg->sendReliable(mCurrHost); | ||
183 | mPending = false; | ||
184 | } | ||
185 | } | ||
188 | 186 | ||
189 | typedef std::set<LLUUID> AskQueue; | 187 | |
190 | typedef std::vector<PendingReply> ReplyQueue; | 188 | typedef std::set<LLUUID> AskQueue; |
191 | typedef std::map<LLUUID,U32> PendingQueue; | 189 | typedef std::vector<PendingReply> ReplyQueue; |
192 | typedef std::map<LLUUID, LLCacheNameEntry*> Cache; | 190 | typedef std::map<LLUUID,U32> PendingQueue; |
193 | typedef std::vector<LLCacheNameCallback> Observers; | 191 | typedef std::map<LLUUID, LLCacheNameEntry*> Cache; |
194 | }; | 192 | typedef std::vector<LLCacheNameCallback> Observers; |
195 | 193 | ||
196 | class LLCacheName::Impl | 194 | class LLCacheName::Impl |
197 | { | 195 | { |