Skip to content

Commit 0744854

Browse files
committed
Populate get_all_products RPC response from secondary manager if
necessary.
1 parent 0750966 commit 0744854

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pc/user.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,16 @@ void user::parse_get_all_products( uint32_t itok )
365365
{
366366
add_header();
367367
jw_.add_key( "result", json_wtr::e_arr );
368-
for( unsigned i=0; i != sptr_->get_num_product(); ++i ) {
369-
product *prod = sptr_->get_product( i );
368+
369+
// If the primary manager has no products, pull them from the secondary
370+
// manager instead.
371+
pc::manager *mgr = sptr_;
372+
if ( sptr_->get_num_product() == 0 && sptr_->has_secondary() ) {
373+
mgr = sptr_->get_secondary();
374+
}
375+
376+
for( unsigned i=0; i != mgr->get_num_product(); ++i ) {
377+
product *prod = mgr->get_product( i );
370378
jw_.add_val( json_wtr::e_obj );
371379
prod->dump_json( jw_ );
372380
jw_.pop();

0 commit comments

Comments
 (0)