Skip to content

Commit 8efd0a9

Browse files
committed
Populate get_all_products RPC response from secondary manager if
necessary.
1 parent 8a4a2e4 commit 8efd0a9

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
@@ -361,8 +361,16 @@ void user::parse_get_all_products( uint32_t itok )
361361
{
362362
add_header();
363363
jw_.add_key( "result", json_wtr::e_arr );
364-
for( unsigned i=0; i != sptr_->get_num_product(); ++i ) {
365-
product *prod = sptr_->get_product( i );
364+
365+
// If the primary manager has no products, pull them from the secondary
366+
// manager instead.
367+
pc::manager *mgr = sptr_;
368+
if ( sptr_->get_num_product() == 0 && sptr_->has_secondary() ) {
369+
mgr = sptr_->get_secondary();
370+
}
371+
372+
for( unsigned i=0; i != mgr->get_num_product(); ++i ) {
373+
product *prod = mgr->get_product( i );
366374
jw_.add_val( json_wtr::e_obj );
367375
prod->dump_json( jw_ );
368376
jw_.pop();

0 commit comments

Comments
 (0)