MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mt_multi_open

Method mt_multi_open

adapter/micro_thread/mt_concurrent.cpp:150–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150int NS_MICRO_THREAD::mt_multi_open(IMtActList& req_list, int timeout)
151{
152 utime64_t start_ms = MtFrame::Instance()->GetLastClock();
153 utime64_t end_ms = start_ms + timeout;
154 utime64_t curr_ms = 0;
155
156 int ret = 0, has_open = 0;
157 IMtAction* action = NULL;
158 IMtConnection* net_handler = NULL;
159 IMtActList::iterator it;
160
161 while (1)
162 {
163 IMtActList wait_list;
164 for (it = req_list.begin(); it != req_list.end(); ++it)
165 {
166 action = *it;
167 if (action->GetErrno() != ERR_NONE) {
168 continue;
169 }
170
171 if (action->GetMsgFlag() == MULTI_FLAG_OPEN) {
172 has_open = 1;
173 continue;
174 }
175
176 net_handler = action->GetIConnection();
177 if (NULL == net_handler)
178 {
179 action->SetErrno(ERR_FRAME_ERROR);
180 MTLOG_ERROR("Invalid param, conn %p null!!", net_handler);
181 return -1;
182 }
183
184 ret = net_handler->OpenCnnect();
185 if (ret < 0)
186 {
187 wait_list.push_back(action);
188 }
189 else
190 {
191 action->SetMsgFlag(MULTI_FLAG_OPEN);
192 }
193 }
194
195 curr_ms = MtFrame::Instance()->GetLastClock();
196 if (curr_ms > end_ms)
197 {
198 MTLOG_DEBUG("Open connect timeout, errno %d", errno);
199 for (IMtActList::iterator it = wait_list.begin(); it != wait_list.end(); ++it)
200 {
201 (*it)->SetErrno(ERR_CONNECT_FAIL);
202 }
203
204 if (!has_open)
205 {
206 return 0;
207 }

Callers

nothing calls this directly

Calls 7

GetLastClockMethod · 0.80
GetErrnoMethod · 0.80
GetMsgFlagMethod · 0.80
GetIConnectionMethod · 0.80
SetErrnoMethod · 0.80
SetMsgFlagMethod · 0.80
OpenCnnectMethod · 0.45

Tested by

no test coverage detected