Changeset 17585

Show
Ignore:
Timestamp:
05/25/06 08:30:30 (3 years ago)
Author:
axeld
Message:

Made the registrar communication more robust (would have cured the symptoms of
bug #513 as well).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • haiku/trunk/src/kits/app/Roster.cpp

    r17478 r17585  
    329329        // compose the request message 
    330330        BMessage request(B_REG_GET_APP_LIST); 
     331 
    331332        // send the request 
    332333        BMessage reply; 
    333334        if (error == B_OK) 
    334335                error = fMessenger.SendMessage(&request, &reply); 
     336 
    335337        // evaluate the reply 
    336338        if (error == B_OK) { 
     
    340342                                teamIDList->AddItem((void*)team); 
    341343                } else { 
    342                         reply.FindInt32("error", &error); 
     344                        if (reply.FindInt32("error", &error) != B_OK) 
     345                                error = B_ERROR; 
    343346                        DBG(OUT("Roster request unsuccessful: %s\n", strerror(error))); 
    344347                        DBG(reply.PrintToStream()); 
     
    369372        if (error == B_OK) 
    370373                error = request.AddString("signature", sig); 
     374 
    371375        // send the request 
    372376        BMessage reply; 
    373377        if (error == B_OK) 
    374378                error = fMessenger.SendMessage(&request, &reply); 
     379 
    375380        // evaluate the reply 
    376381        if (error == B_OK) { 
     
    379384                        for (int32 i = 0; reply.FindInt32("teams", i, &team) == B_OK; i++) 
    380385                                teamIDList->AddItem((void*)team); 
    381                 } else 
    382                         reply.FindInt32("error", &error); 
     386                } else if (reply.FindInt32("error", &error) != B_OK) 
     387                        error = B_ERROR; 
    383388        } 
    384389} 
     
    404409        if (error == B_OK) 
    405410                error = request.AddString("signature", sig); 
     411 
    406412        // send the request 
    407413        BMessage reply; 
    408414        if (error == B_OK) 
    409415                error = fMessenger.SendMessage(&request, &reply); 
     416 
    410417        // evaluate the reply 
    411418        if (error == B_OK) { 
    412419                if (reply.what == B_REG_SUCCESS) 
    413420                        error = find_message_app_info(&reply, info); 
    414                 else 
    415                         reply.FindInt32("error", &error); 
     421                else if (reply.FindInt32("error", &error) != B_OK) 
     422                        error = B_ERROR; 
    416423        } 
    417424        return error; 
     
    438445        if (error == B_OK) 
    439446                error = request.AddRef("ref", ref); 
     447 
    440448        // send the request 
    441449        BMessage reply; 
    442450        if (error == B_OK) 
    443451                error = fMessenger.SendMessage(&request, &reply); 
     452 
    444453        // evaluate the reply 
    445454        if (error == B_OK) { 
    446455                if (reply.what == B_REG_SUCCESS) 
    447456                        error = find_message_app_info(&reply, info); 
    448                 else 
    449                         reply.FindInt32("error", &error); 
     457                else if (reply.FindInt32("error", &error) != B_OK) 
     458                        error = B_ERROR; 
    450459        } 
    451460        return error; 
     
    477486        if (error == B_OK) 
    478487                error = fMessenger.SendMessage(&request, &reply); 
     488 
    479489        // evaluate the reply 
    480490        if (error == B_OK) { 
    481491                if (reply.what == B_REG_SUCCESS) 
    482492                        error = find_message_app_info(&reply, info); 
    483                 else 
    484                         reply.FindInt32("error", &error); 
     493                else if (reply.FindInt32("error", &error) != B_OK) 
     494                        error = B_ERROR; 
    485495        } 
    486496        return error; 
     
    510520                if (reply.what == B_REG_SUCCESS) 
    511521                        error = find_message_app_info(&reply, info); 
    512                 else 
    513                         reply.FindInt32("error", &error); 
     522                else if (reply.FindInt32("error", &error) != B_OK) 
     523                        error = B_ERROR; 
    514524        } 
    515525        return error; 
     
    649659        if (error == B_OK) 
    650660                error = request.AddMessenger("reply_target", replyTo); 
     661 
    651662        // send the request 
    652663        BMessage reply; 
    653664        if (error == B_OK) 
    654665                error = fMessenger.SendMessage(&request, &reply); 
     666 
    655667        // evaluate the reply 
    656         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    657                 reply.FindInt32("error", &error); 
     668        if (error == B_OK && reply.what != B_REG_SUCCESS 
     669                && reply.FindInt32("error", &error) != B_OK) 
     670                error = B_ERROR; 
     671 
    658672        return error; 
    659673} 
     
    703717        if (error == B_OK) 
    704718                error = request.AddInt32("events", (int32)eventMask); 
     719 
    705720        // send the request 
    706721        BMessage reply; 
    707722        if (error == B_OK) 
    708723                error = fMessenger.SendMessage(&request, &reply); 
     724 
    709725        // evaluate the reply 
    710         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    711                 reply.FindInt32("error", &error); 
     726        if (error == B_OK && reply.what != B_REG_SUCCESS 
     727                && reply.FindInt32("error", &error) != B_OK) 
     728                error = B_ERROR; 
     729 
    712730        return error; 
    713731} 
     
    729747        if (error == B_OK) 
    730748                error = request.AddMessenger("target", target); 
     749 
    731750        // send the request 
    732751        BMessage reply; 
    733752        if (error == B_OK) 
    734753                error = fMessenger.SendMessage(&request, &reply); 
     754 
    735755        // evaluate the reply 
    736         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    737                 reply.FindInt32("error", &error); 
     756        if (error == B_OK && reply.what != B_REG_SUCCESS 
     757                && reply.FindInt32("error", &error) != B_OK) 
     758                error = B_ERROR; 
     759 
    738760        return error; 
    739761} 
     
    13611383 
    13621384        // evaluate the reply 
    1363         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1364                 reply.FindInt32("error", &error); 
     1385        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1386                && reply.FindInt32("error", &error) != B_OK) 
     1387                error = B_ERROR; 
    13651388 
    13661389        return error; 
     
    14491472                        } 
    14501473                } else { 
    1451                         reply.FindInt32("error", &error); 
     1474                        if (reply.FindInt32("error", &error) != B_OK) 
     1475                                error = B_ERROR; 
    14521476                        if (otherTeam) 
    14531477                                reply.FindInt32("other_team", otherTeam); 
     
    14801504        if (error == B_OK && mimeSig) 
    14811505                error = request.AddString("signature", mimeSig); 
     1506 
    14821507        // send the request 
    14831508        BMessage reply; 
    14841509        if (error == B_OK) 
    14851510                error = fMessenger.SendMessage(&request, &reply); 
     1511 
    14861512        // evaluate the reply 
    1487         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1488                 reply.FindInt32("error", &error); 
     1513        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1514                && reply.FindInt32("error", &error) != B_OK) 
     1515                error = B_ERROR; 
     1516 
    14891517        return error; 
    14901518} 
     
    15281556        if (error == B_OK && thread >= 0) 
    15291557                error = request.AddInt32("thread", thread); 
     1558 
    15301559        // send the request 
    15311560        BMessage reply; 
    15321561        if (error == B_OK) 
    15331562                error = fMessenger.SendMessage(&request, &reply); 
     1563 
    15341564        // evaluate the reply 
    1535         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1536                 reply.FindInt32("error", &error); 
     1565        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1566                && reply.FindInt32("error", &error) != B_OK) 
     1567                error = B_ERROR; 
     1568 
    15371569        return error; 
    15381570} 
     
    15661598        if (error == B_OK && port >= 0) 
    15671599                error = request.AddInt32("port", port); 
     1600 
    15681601        // send the request 
    15691602        BMessage reply; 
    15701603        if (error == B_OK) 
    15711604                error = fMessenger.SendMessage(&request, &reply); 
     1605 
    15721606        // evaluate the reply 
    1573         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1574                 reply.FindInt32("error", &error); 
     1607        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1608                && reply.FindInt32("error", &error) != B_OK) 
     1609                error = B_ERROR; 
     1610 
    15751611        return error; 
    15761612} 
     
    16121648                        if (error == B_OK && isPreRegistered && info) 
    16131649                                error = find_message_app_info(&reply, info); 
    1614                 } else 
    1615                         reply.FindInt32("error", &error); 
    1616         } 
    1617         return (error == B_OK && isPreRegistered); 
     1650                } else if (reply.FindInt32("error", &error) != B_OK) 
     1651                        error = B_ERROR; 
     1652        } 
     1653        return error == B_OK && isPreRegistered; 
    16181654} 
    16191655 
     
    16401676        if (error == B_OK) 
    16411677                error = request.AddInt32("token", (int32)entryToken); 
     1678 
    16421679        // send the request 
    16431680        BMessage reply; 
    16441681        if (error == B_OK) 
    16451682                error = fMessenger.SendMessage(&request, &reply); 
     1683 
    16461684        // evaluate the reply 
    1647         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1648                 reply.FindInt32("error", &error); 
     1685        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1686                && reply.FindInt32("error", &error) != B_OK) 
     1687                error = B_ERROR; 
     1688 
    16491689        return error; 
    16501690} 
     
    16711711        if (error == B_OK && team >= 0) 
    16721712                error = request.AddInt32("team", team); 
     1713 
    16731714        // send the request 
    16741715        BMessage reply; 
    16751716        if (error == B_OK) 
    16761717                error = fMessenger.SendMessage(&request, &reply); 
     1718 
    16771719        // evaluate the reply 
    1678         if (error == B_OK && reply.what != B_REG_SUCCESS) 
    1679                 reply.FindInt32("error", &error); 
     1720        if (error == B_OK && reply.what != B_REG_SUCCESS 
     1721                && reply.FindInt32("error", &error) != B_OK) 
     1722                error = B_ERROR; 
     1723 
    16801724        return error; 
    16811725}