|
|
|
@@ -219,65 +219,64 @@ class example_rp_t : public opkele::prequeue_RP { |
219 | "SELECT" |
219 | "SELECT" |
220 | " eq_uri, eq_claimed_id, eq_local_id" |
220 | " eq_uri, eq_claimed_id, eq_local_id" |
221 | " FROM endpoints_queue" |
221 | " FROM endpoints_queue" |
222 | " JOIN auth_sessions USING(as_id)" |
222 | " JOIN auth_sessions USING(as_id)" |
223 | " WHERE hts_id=%Q AND as_id=%ld" |
223 | " WHERE hts_id=%Q AND as_id=%ld" |
224 | " ORDER BY eq_ctime,eq_ordinal" |
224 | " ORDER BY eq_ctime,eq_ordinal" |
225 | " LIMIT 1",htc.get_value().c_str(),as_id); |
225 | " LIMIT 1",htc.get_value().c_str(),as_id); |
226 | sqlite3_table_t T; int nr,nc; |
226 | sqlite3_table_t T; int nr,nc; |
227 | db.get_table(S,T,&nr,&nc); |
227 | db.get_table(S,T,&nr,&nc); |
228 | if(nr<1) |
228 | if(nr<1) |
229 | throw opkele::exception(OPKELE_CP_ "No more endpoints queued"); |
229 | throw opkele::exception(OPKELE_CP_ "No more endpoints queued"); |
230 | assert(nr==1); assert(nc==3); |
230 | assert(nr==1); assert(nc==3); |
231 | eqtop.uri = T.get(1,0,nc); |
231 | eqtop.uri = T.get(1,0,nc); |
232 | eqtop.claimed_id = T.get(1,1,nc); |
232 | eqtop.claimed_id = T.get(1,1,nc); |
233 | eqtop.local_id = T.get(1,2,nc); |
233 | eqtop.local_id = T.get(1,2,nc); |
234 | have_eqtop = true; |
234 | have_eqtop = true; |
235 | } |
235 | } |
236 | return eqtop; |
236 | return eqtop; |
237 | } |
237 | } |
238 | |
238 | |
239 | void next_endpoint() { |
239 | void next_endpoint() { |
240 | assert(as_id>=0); |
240 | assert(as_id>=0); |
241 | get_endpoint(); |
241 | get_endpoint(); |
242 | have_eqtop = false; |
242 | have_eqtop = false; |
243 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
243 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
244 | "DELETE FROM endpoints_queue" |
244 | "DELETE FROM endpoints_queue" |
245 | " WHERE as_id=%ld AND eq_uri=%Q AND eq_local_id=%Q", |
245 | " WHERE as_id=%ld AND eq_uri=%Q AND eq_local_id=%Q", |
246 | htc.get_value().c_str(),as_id, |
246 | htc.get_value().c_str(),as_id, |
247 | eqtop.uri.c_str()); |
247 | eqtop.uri.c_str()); |
248 | db.exec(S); |
248 | db.exec(S); |
249 | } |
249 | } |
250 | |
250 | |
251 | mutable string _cid; |
| |
252 | mutable string _nid; |
251 | mutable string _nid; |
253 | |
252 | |
254 | void set_normalized_id(const string& nid) { |
253 | void set_normalized_id(const string& nid) { |
255 | assert(as_id>=0); |
254 | assert(as_id>=0); |
256 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
255 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
257 | "UPDATE auth_sessions" |
256 | "UPDATE auth_sessions" |
258 | " SET as_normalized_id=%Q" |
257 | " SET as_normalized_id=%Q" |
259 | " WHERE hts_id=%Q and as_id=%ld", |
258 | " WHERE hts_id=%Q and as_id=%ld", |
260 | nid.c_str(), |
259 | nid.c_str(), |
261 | htc.get_value().c_str(),as_id); |
260 | htc.get_value().c_str(),as_id); |
262 | db.exec(S); |
261 | db.exec(S); |
263 | _nid = nid; |
262 | _nid = nid; |
264 | } |
263 | } |
265 | const string get_normalized_id() const { |
264 | const string get_normalized_id() const { |
266 | assert(as_id>=0); |
265 | assert(as_id>=0); |
267 | if(_nid.empty()) { |
266 | if(_nid.empty()) { |
268 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
267 | sqlite3_mem_t<char*> S = sqlite3_mprintf( |
269 | "SELECT as_normalized_id" |
268 | "SELECT as_normalized_id" |
270 | " FROM" |
269 | " FROM" |
271 | " auth_sessions" |
270 | " auth_sessions" |
272 | " WHERE" |
271 | " WHERE" |
273 | " hts_id=%Q AND as_id=%ld", |
272 | " hts_id=%Q AND as_id=%ld", |
274 | htc.get_value().c_str(),as_id); |
273 | htc.get_value().c_str(),as_id); |
275 | sqlite3_table_t T; int nr,nc; |
274 | sqlite3_table_t T; int nr,nc; |
276 | db.get_table(S,T,&nr,&nc); |
275 | db.get_table(S,T,&nr,&nc); |
277 | assert(nr==1); assert(nc==1); |
276 | assert(nr==1); assert(nc==1); |
278 | _nid = T.get(1,0,nc); |
277 | _nid = T.get(1,0,nc); |
279 | } |
278 | } |
280 | return _nid; |
279 | return _nid; |
281 | } |
280 | } |
282 | |
281 | |
283 | const string get_this_url() const { |
282 | const string get_this_url() const { |
|