MCPcopy Create free account
hub / github.com/acl-dev/acl / beanstalk_request

Method beanstalk_request

lib_acl_cpp/src/beanstalk/beanstalk.cpp:153–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153ACL_ARGV* beanstalk::beanstalk_request(const string& cmdline,
154 const void* data /*= NULL */, size_t len /* = 0 */)
155{
156 string line(128);
157 bool retried = false;
158
159 while (true) {
160 if (!beanstalk_open()) {
161 return NULL;
162 }
163
164 // ��д������ͷ
165 if (conn_.write(cmdline) == -1) {
166 conn_.close();
167 if (retry_ && !retried) {
168 retried = true;
169 continue;
170 }
171 logger_error("write to beanstalkd(%s) error: %s",
172 addr_, last_serror());
173 errbuf_ = "write";
174 return NULL;
175 }
176
177 // ����������壬��д��������
178 if (data && len > 0 && (conn_.write(data, len) == -1
179 || conn_.write("\r\n", 2) == -1)) {
180
181 conn_.close();
182 if (retry_ && !retried) {
183 retried = true;
184 continue;
185 }
186 logger_error("write to beanstalkd(%s) error: %s",
187 addr_, last_serror());
188 errbuf_ = "write";
189 return NULL;
190 }
191
192 line.clear();
193 if (!conn_.gets(line) || line.empty()) {
194 conn_.close();
195 if (retry_ && !retried) {
196 retried = true;
197 continue;
198 }
199 logger_error("gets from beanstalkd(%s) error: %s",
200 addr_, last_serror());
201 errbuf_ = "gets";
202 return NULL;
203 }
204 break;
205 }
206
207 ACL_ARGV* tokens = acl_argv_split(line.c_str(), "\t ");
208 return tokens;
209}
210

Callers

nothing calls this directly

Calls 8

acl_argv_splitFunction · 0.85
getsMethod · 0.80
last_serrorFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected