* Fix debug build of the registrar.

* Make the macros use varargs so we avoid multiple invokations of the print
  function (to properly use with debug_printf for example).
* Minor cleanup to the macros.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42848 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2011-10-14 11:57:39 +00:00
parent 53aac74407
commit e09045d41f
7 changed files with 151 additions and 137 deletions
+28 -14
View File
@@ -35,28 +35,42 @@
#define DEBUG_APP "REG" #define DEBUG_APP "REG"
#if DEBUG #if DEBUG
#define PRINT(x) { __out(DEBUG_APP ": "); __out x; } #define PRINT(x...) { __out(DEBUG_APP ": " x); }
#define REPORT_ERROR(status) __out(DEBUG_APP ": %s:%d: %s\n",__FUNCTION__,__LINE__,strerror(status)); #define REPORT_ERROR(status) \
#define RETURN_ERROR(err) { status_t _status = err; if (_status < B_OK) REPORT_ERROR(_status); return _status;} __out(DEBUG_APP ": %s:%d: %s\n", __FUNCTION__, __LINE__, \
#define SET_ERROR(var, err) { status_t _status = err; if (_status < B_OK) REPORT_ERROR(_status); var = _status; } strerror(status));
#define FATAL(x) { __out(DEBUG_APP ": "); __out x; } #define RETURN_ERROR(err) \
#define ERROR(x) { __out(DEBUG_APP ": "); __out x; } { \
#define WARNING(x) { __out(DEBUG_APP ": "); __out x; } status_t _status = err; \
#define INFORM(x) { __out(DEBUG_APP ": "); __out x; } if (_status < B_OK) \
REPORT_ERROR(_status); \
return _status; \
}
#define SET_ERROR(var, err) \
{ \
status_t _status = err; \
if (_status < B_OK) \
REPORT_ERROR(_status); \
var = _status; \
}
#define FATAL(x...) { __out(DEBUG_APP ": " x); }
#define ERROR(x...) { __out(DEBUG_APP ": " x); }
#define WARNING(x...) { __out(DEBUG_APP ": " x); }
#define INFORM(x...) { __out(DEBUG_APP ": " x); }
#define FUNCTION(x) { __out(DEBUG_APP ": %s() ",__FUNCTION__); __out x; } #define FUNCTION(x) { __out(DEBUG_APP ": %s() ",__FUNCTION__); __out x; }
#define FUNCTION_START() { __out(DEBUG_APP ": %s()\n",__FUNCTION__); } #define FUNCTION_START() { __out(DEBUG_APP ": %s()\n",__FUNCTION__); }
#define FUNCTION_END() { __out(DEBUG_APP ": %s() done\n",__FUNCTION__); } #define FUNCTION_END() { __out(DEBUG_APP ": %s() done\n",__FUNCTION__); }
#define D(x) {x;}; #define D(x) {x;};
#else #else
#define PRINT(x) ; #define PRINT(x...) ;
#define REPORT_ERROR(status) ; #define REPORT_ERROR(status) ;
#define RETURN_ERROR(status) return status; #define RETURN_ERROR(status) return status;
#define SET_ERROR(var, err) var = err; #define SET_ERROR(var, err) var = err;
#define FATAL(x) { __out(DEBUG_APP ": "); __out x; } #define FATAL(x...) { __out(DEBUG_APP ": " x); }
#define ERROR(x) { __out(DEBUG_APP ": "); __out x; } #define ERROR(x...) { __out(DEBUG_APP ": " x); }
#define WARNING(x) { __out(DEBUG_APP ": "); __out x; } #define WARNING(x...) { __out(DEBUG_APP ": " x); }
#define INFORM(x) { __out(DEBUG_APP ": "); __out x; } #define INFORM(x...) { __out(DEBUG_APP ": " x); }
#define FUNCTION(x) ; #define FUNCTION(x...) ;
#define FUNCTION_START() ; #define FUNCTION_START() ;
#define FUNCTION_END() ; #define FUNCTION_END() ;
#define D(x) ; #define D(x) ;
+14 -14
View File
@@ -356,8 +356,8 @@ public:
status_t PushMessage(Message *message, int32 token) status_t PushMessage(Message *message, int32 token)
{ {
PRINT(("MessageDeliverer::TargetPort::PushMessage(port: %ld, %p, %ld)\n", PRINT("MessageDeliverer::TargetPort::PushMessage(port: %ld, %p, %ld)\n",
fPortID, message, token)); fPortID, message, token);
// create a target message // create a target message
TargetMessage *targetMessage TargetMessage *targetMessage
= new(nothrow) TargetMessage(message, token); = new(nothrow) TargetMessage(message, token);
@@ -390,8 +390,8 @@ fPortID, message, token));
void PopMessage() void PopMessage()
{ {
if (fMessages.Head()) { if (fMessages.Head()) {
PRINT(("MessageDeliverer::TargetPort::PopMessage(): port: %ld, %p\n", PRINT("MessageDeliverer::TargetPort::PopMessage(): port: %ld, %p\n",
fPortID, fMessages.Head()->GetMessage())); fPortID, fMessages.Head()->GetMessage());
_RemoveMessage(fMessages.Head()); _RemoveMessage(fMessages.Head());
} }
} }
@@ -405,8 +405,8 @@ fPortID, fMessages.Head()->GetMessage()));
if (message->GetMessage()->TimeoutTime() > now) if (message->GetMessage()->TimeoutTime() > now)
break; break;
PRINT(("MessageDeliverer::TargetPort::DropTimedOutMessages(): port: %ld: " PRINT("MessageDeliverer::TargetPort::DropTimedOutMessages(): port: %ld: "
"message %p timed out\n", fPortID, message->GetMessage())); "message %p timed out\n", fPortID, message->GetMessage());
_RemoveMessage(message); _RemoveMessage(message);
} }
} }
@@ -433,15 +433,15 @@ private:
{ {
// message count // message count
while (fMessageCount > kMaxMessagesPerPort) { while (fMessageCount > kMaxMessagesPerPort) {
PRINT(("MessageDeliverer::TargetPort::_EnforceLimits(): port: %ld: hit maximum " PRINT("MessageDeliverer::TargetPort::_EnforceLimits(): port: %ld: hit maximum "
"message count limit.\n", fPortID)); "message count limit.\n", fPortID);
PopMessage(); PopMessage();
} }
// message size // message size
while (fMessageSize > kMaxDataPerPort) { while (fMessageSize > kMaxDataPerPort) {
PRINT(("MessageDeliverer::TargetPort::_EnforceLimits(): port: %ld: hit maximum " PRINT("MessageDeliverer::TargetPort::_EnforceLimits(): port: %ld: hit maximum "
"message size limit.\n", fPortID)); "message size limit.\n", fPortID);
PopMessage(); PopMessage();
} }
} }
@@ -735,8 +735,8 @@ MessageDeliverer::_SendMessage(Message *message, port_id portID, int32 token)
{ {
status_t error = BMessage::Private::SendFlattenedMessage(message->Data(), status_t error = BMessage::Private::SendFlattenedMessage(message->Data(),
message->DataSize(), portID, token, 0); message->DataSize(), portID, token, 0);
//PRINT(("MessageDeliverer::_SendMessage(%p, port: %ld, token: %ld): %lx\n", //PRINT("MessageDeliverer::_SendMessage(%p, port: %ld, token: %ld): %lx\n",
//message, portID, token, error)); //message, portID, token, error);
return error; return error;
} }
@@ -773,8 +773,8 @@ MessageDeliverer::_DelivererThread()
error = _SendMessage(message, port->PortID(), token); error = _SendMessage(message, port->PortID(), token);
// } else { // } else {
// // timeout, drop message // // timeout, drop message
// PRINT(("MessageDeliverer::_DelivererThread(): port %ld, " // PRINT("MessageDeliverer::_DelivererThread(): port %ld, "
// "message %p timed out\n", port->PortID(), message)); // "message %p timed out\n", port->PortID(), message);
// } // }
if (error == B_OK) { if (error == B_OK) {
@@ -751,8 +751,8 @@ MessageRunnerManager::_ScheduleEvent(RunnerInfo *info)
info->event->SetTime(info->time); info->event->SetTime(info->time);
scheduled = fEventQueue->AddEvent(info->event); scheduled = fEventQueue->AddEvent(info->event);
PRINT(("runner %ld (%lld, %ld) rescheduled: %d, time: %lld, now: %lld\n", PRINT("runner %ld (%lld, %ld) rescheduled: %d, time: %lld, now: %lld\n",
info->token, info->interval, info->count, scheduled, info->time, system_time())); info->token, info->interval, info->count, scheduled, info->time, system_time());
} }
return scheduled; return scheduled;
} }
+8 -8
View File
@@ -408,13 +408,13 @@ MessagingService::_CommandProcessor()
const messaging_command *command = area->PopCommand(); const messaging_command *command = area->PopCommand();
if (!command) { if (!command) {
// something's seriously wrong // something's seriously wrong
ERROR(("MessagingService::_CommandProcessor(): area %p (%ld) " ERROR("MessagingService::_CommandProcessor(): area %p (%ld) "
"has command count %ld, but doesn't return any more " "has command count %ld, but doesn't return any more "
"commands.", area, area->ID(), area->CountCommands())); "commands.", area, area->ID(), area->CountCommands());
break; break;
} }
PRINT(("MessagingService::_CommandProcessor(): got command %lu\n", PRINT("MessagingService::_CommandProcessor(): got command %lu\n",
command->command)); command->command);
// dispatch the command // dispatch the command
MessagingCommandHandler *handler MessagingCommandHandler *handler
@@ -423,8 +423,8 @@ command->command));
handler->HandleMessagingCommand(command->command, command->data, handler->HandleMessagingCommand(command->command, command->data,
command->size - sizeof(messaging_command)); command->size - sizeof(messaging_command));
} else { } else {
WARNING(("MessagingService::_CommandProcessor(): No handler " WARNING("MessagingService::_CommandProcessor(): No handler "
"found for command %lu\n", command->command)); "found for command %lu\n", command->command);
} }
} }
@@ -439,9 +439,9 @@ command->command));
commandWaiting = true; commandWaiting = true;
} else { } else {
// Bad, but what can we do? // Bad, but what can we do?
ERROR(("MessagingService::_CommandProcessor(): Failed to clone " ERROR("MessagingService::_CommandProcessor(): Failed to clone "
"kernel area %ld: %s\n", area->NextKernelAreaID(), "kernel area %ld: %s\n", area->NextKernelAreaID(),
strerror(error))); strerror(error));
} }
} }
+9 -9
View File
@@ -130,8 +130,8 @@ Registrar::ReadyToRun()
// create message deliverer // create message deliverer
status_t error = MessageDeliverer::CreateDefault(); status_t error = MessageDeliverer::CreateDefault();
if (error != B_OK) { if (error != B_OK) {
FATAL(("Registrar::ReadyToRun(): Failed to create the message " FATAL("Registrar::ReadyToRun(): Failed to create the message "
"deliverer: %s\n", strerror(error))); "deliverer: %s\n", strerror(error));
} }
// create event queue // create event queue
@@ -162,8 +162,8 @@ Registrar::ReadyToRun()
// create the messaging service // create the messaging service
error = MessagingService::CreateDefault(); error = MessagingService::CreateDefault();
if (error != B_OK) { if (error != B_OK) {
ERROR(("Registrar::ReadyToRun(): Failed to init messaging service " ERROR("Registrar::ReadyToRun(): Failed to init messaging service "
"(that's by design when running under R5): %s\n", strerror(error))); "(that's by design when running under R5): %s\n", strerror(error));
} }
// create and schedule the sanity message event // create and schedule the sanity message event
@@ -215,7 +215,7 @@ Registrar::_MessageReceived(BMessage *message)
// general requests // general requests
case B_REG_GET_MIME_MESSENGER: case B_REG_GET_MIME_MESSENGER:
{ {
PRINT(("B_REG_GET_MIME_MESSENGER\n")); PRINT("B_REG_GET_MIME_MESSENGER\n");
BMessenger messenger(NULL, fMIMEManager); BMessenger messenger(NULL, fMIMEManager);
BMessage reply(B_REG_SUCCESS); BMessage reply(B_REG_SUCCESS);
reply.AddMessenger("messenger", messenger); reply.AddMessenger("messenger", messenger);
@@ -225,7 +225,7 @@ Registrar::_MessageReceived(BMessage *message)
case B_REG_GET_CLIPBOARD_MESSENGER: case B_REG_GET_CLIPBOARD_MESSENGER:
{ {
PRINT(("B_REG_GET_CLIPBOARD_MESSENGER\n")); PRINT("B_REG_GET_CLIPBOARD_MESSENGER\n");
BMessenger messenger(fClipboardHandler); BMessenger messenger(fClipboardHandler);
BMessage reply(B_REG_SUCCESS); BMessage reply(B_REG_SUCCESS);
reply.AddMessenger("messenger", messenger); reply.AddMessenger("messenger", messenger);
@@ -236,7 +236,7 @@ Registrar::_MessageReceived(BMessage *message)
// shutdown process // shutdown process
case B_REG_SHUT_DOWN: case B_REG_SHUT_DOWN:
{ {
PRINT(("B_REG_SHUT_DOWN\n")); PRINT("B_REG_SHUT_DOWN\n");
_HandleShutDown(message); _HandleShutDown(message);
break; break;
@@ -425,7 +425,7 @@ main()
// rename the main thread // rename the main thread
rename_thread(find_thread(NULL), kRosterThreadName); rename_thread(find_thread(NULL), kRosterThreadName);
PRINT(("app->Run()...\n")); PRINT("app->Run()...\n");
try { try {
app->Run(); app->Run();
@@ -438,7 +438,7 @@ main()
debugger("registrar main() caught unknown exception"); debugger("registrar main() caught unknown exception");
} }
PRINT(("delete app...\n")); PRINT("delete app...\n");
delete app; delete app;
FUNCTION_END(); FUNCTION_END();
+54 -54
View File
@@ -670,7 +670,7 @@ ShutdownProcess::~ShutdownProcess()
status_t status_t
ShutdownProcess::Init(BMessage* request) ShutdownProcess::Init(BMessage* request)
{ {
PRINT(("ShutdownProcess::Init()\n")); PRINT("ShutdownProcess::Init()\n");
// create and add the quit request reply handler // create and add the quit request reply handler
fQuitRequestReplyHandler = new(nothrow) QuitRequestReplyHandler(this); fQuitRequestReplyHandler = new(nothrow) QuitRequestReplyHandler(this);
@@ -720,7 +720,7 @@ ShutdownProcess::Init(BMessage* request)
resume_thread(fWorker); resume_thread(fWorker);
PRINT(("ShutdownProcess::Init() done\n")); PRINT("ShutdownProcess::Init() done\n");
return B_OK; return B_OK;
} }
@@ -739,8 +739,8 @@ ShutdownProcess::MessageReceived(BMessage* message)
return; return;
} }
PRINT(("ShutdownProcess::MessageReceived(): B_SOME_APP_QUIT: %ld\n", PRINT("ShutdownProcess::MessageReceived(): B_SOME_APP_QUIT: %ld\n",
team)); team);
// remove the app info from the respective list // remove the app info from the respective list
int32 phase; int32 phase;
@@ -774,7 +774,7 @@ ShutdownProcess::MessageReceived(BMessage* message)
// get the phase the event is intended for // get the phase the event is intended for
int32 phase = TimeoutEvent::GetMessagePhase(message); int32 phase = TimeoutEvent::GetMessagePhase(message);
team_id team = TimeoutEvent::GetMessageTeam(message);; team_id team = TimeoutEvent::GetMessageTeam(message);;
PRINT(("MSG_PHASE_TIMED_OUT: phase: %ld, team: %ld\n", phase, team)); PRINT("MSG_PHASE_TIMED_OUT: phase: %ld, team: %ld\n", phase, team);
BAutolock _(fWorkerLock); BAutolock _(fWorkerLock);
@@ -837,10 +837,10 @@ ShutdownProcess::MessageReceived(BMessage* message)
BAutolock _(fWorkerLock); BAutolock _(fWorkerLock);
if (open) { if (open) {
PRINT(("B_REG_TEAM_DEBUGGER_ALERT: insert %ld\n", team)); PRINT("B_REG_TEAM_DEBUGGER_ALERT: insert %ld\n", team);
fDebuggedTeams.insert(team); fDebuggedTeams.insert(team);
} else { } else {
PRINT(("B_REG_TEAM_DEBUGGER_ALERT: remove %ld\n", team)); PRINT("B_REG_TEAM_DEBUGGER_ALERT: remove %ld\n", team);
fDebuggedTeams.erase(team); fDebuggedTeams.erase(team);
_PushEvent(DEBUG_EVENT, -1, fCurrentPhase); _PushEvent(DEBUG_EVENT, -1, fCurrentPhase);
} }
@@ -947,8 +947,8 @@ ShutdownProcess::_InitShutdownWindow()
_AddShutdownWindowApps(fUserApps); _AddShutdownWindowApps(fUserApps);
_AddShutdownWindowApps(fSystemApps); _AddShutdownWindowApps(fSystemApps);
} else { } else {
WARNING(("ShutdownProcess::Init(): Failed to create or init " WARNING("ShutdownProcess::Init(): Failed to create or init "
"shutdown window.")); "shutdown window.");
fHasGUI = false; fHasGUI = false;
} }
@@ -969,18 +969,18 @@ ShutdownProcess::_AddShutdownWindowApps(AppInfoList& infos)
BFile file; BFile file;
status_t error = file.SetTo(&info->ref, B_READ_ONLY); status_t error = file.SetTo(&info->ref, B_READ_ONLY);
if (error != B_OK) { if (error != B_OK) {
WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " WARNING("ShutdownProcess::_AddShutdownWindowApps(): Failed to "
"open file for app %s: %s\n", info->signature, "open file for app %s: %s\n", info->signature,
strerror(error))); strerror(error));
continue; continue;
} }
BAppFileInfo appFileInfo; BAppFileInfo appFileInfo;
error = appFileInfo.SetTo(&file); error = appFileInfo.SetTo(&file);
if (error != B_OK) { if (error != B_OK) {
WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " WARNING("ShutdownProcess::_AddShutdownWindowApps(): Failed to "
"init app file info for app %s: %s\n", info->signature, "init app file info for app %s: %s\n", info->signature,
strerror(error))); strerror(error));
} }
// get the application icons // get the application icons
@@ -1017,8 +1017,8 @@ ShutdownProcess::_AddShutdownWindowApps(AppInfoList& infos)
// add the app // add the app
error = fWindow->AddApp(info->team, miniIcon, largeIcon); error = fWindow->AddApp(info->team, miniIcon, largeIcon);
if (error != B_OK) { if (error != B_OK) {
WARNING(("ShutdownProcess::_AddShutdownWindowApps(): Failed to " WARNING("ShutdownProcess::_AddShutdownWindowApps(): Failed to "
"add app to the shutdown window: %s\n", strerror(error))); "add app to the shutdown window: %s\n", strerror(error));
} }
} }
} }
@@ -1126,7 +1126,7 @@ ShutdownProcess::_PrepareShutdownMessage(BMessage& message) const
status_t status_t
ShutdownProcess::_ShutDown() ShutdownProcess::_ShutDown()
{ {
PRINT(("Invoking _kern_shutdown(%d)\n", fReboot)); PRINT("Invoking _kern_shutdown(%d)\n", fReboot);
RETURN_ERROR(_kern_shutdown(fReboot)); RETURN_ERROR(_kern_shutdown(fReboot));
} }
@@ -1136,7 +1136,7 @@ ShutdownProcess::_PushEvent(uint32 eventType, team_id team, int32 phase)
{ {
InternalEvent* event = new(nothrow) InternalEvent(eventType, team, phase); InternalEvent* event = new(nothrow) InternalEvent(eventType, team, phase);
if (!event) { if (!event) {
ERROR(("ShutdownProcess::_PushEvent(): Failed to create event!\n")); ERROR("ShutdownProcess::_PushEvent(): Failed to create event!\n");
return B_NO_MEMORY; return B_NO_MEMORY;
} }
@@ -1214,8 +1214,8 @@ ShutdownProcess::_Worker()
_WorkerDoShutdown(); _WorkerDoShutdown();
fShutdownError = B_OK; fShutdownError = B_OK;
} catch (status_t error) { } catch (status_t error) {
PRINT(("ShutdownProcess::_Worker(): error while shutting down: %s\n", PRINT("ShutdownProcess::_Worker(): error while shutting down: %s\n",
strerror(error))); strerror(error));
fShutdownError = error; fShutdownError = error;
} }
@@ -1232,7 +1232,7 @@ ShutdownProcess::_Worker()
void void
ShutdownProcess::_WorkerDoShutdown() ShutdownProcess::_WorkerDoShutdown()
{ {
PRINT(("ShutdownProcess::_WorkerDoShutdown()\n")); PRINT("ShutdownProcess::_WorkerDoShutdown()\n");
// If we are here, the shutdown process has been initiated successfully, // If we are here, the shutdown process has been initiated successfully,
// that is, if an asynchronous BRoster::Shutdown() was requested, we // that is, if an asynchronous BRoster::Shutdown() was requested, we
@@ -1336,7 +1336,7 @@ ShutdownProcess::_WorkerDoShutdown()
_ShutDown(); _ShutDown();
_SetShutdownWindowWaitForShutdown(); _SetShutdownWindowWaitForShutdown();
PRINT((" _kern_shutdown() failed\n")); PRINT(" _kern_shutdown() failed\n");
// shutdown failed: This can happen for power off mode -- reboot should // shutdown failed: This can happen for power off mode -- reboot should
// always work. // always work.
@@ -1397,8 +1397,8 @@ ShutdownProcess::_WaitForApp(team_id team, AppInfoList* list, bool systemApps)
return false; return false;
} else { } else {
// The app returned false in QuitRequested(). // The app returned false in QuitRequested().
PRINT(("ShutdownProcess::_WaitForApp(): shutdown cancelled " PRINT("ShutdownProcess::_WaitForApp(): shutdown cancelled "
"by team %ld (-1 => user)\n", eventTeam)); "by team %ld (-1 => user)\n", eventTeam);
_DisplayAbortingApp(team); _DisplayAbortingApp(team);
throw_error(B_SHUTDOWN_CANCELLED); throw_error(B_SHUTDOWN_CANCELLED);
@@ -1417,8 +1417,8 @@ ShutdownProcess::_WaitForApp(team_id team, AppInfoList* list, bool systemApps)
void void
ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps) ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
{ {
PRINT(("ShutdownProcess::_QuitApps(%s)\n", PRINT("ShutdownProcess::_QuitApps(%s)\n",
(systemApps ? "system" : "user"))); (systemApps ? "system" : "user"));
if (systemApps) { if (systemApps) {
_SetShutdownWindowCancelButtonEnabled(false); _SetShutdownWindowCancelButtonEnabled(false);
@@ -1433,8 +1433,8 @@ ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
throw_error(error); throw_error(error);
if (event == ABORT_EVENT) { if (event == ABORT_EVENT) {
PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled by " PRINT("ShutdownProcess::_QuitApps(): shutdown cancelled by "
"team %ld (-1 => user)\n", team)); "team %ld (-1 => user)\n", team);
_DisplayAbortingApp(team); _DisplayAbortingApp(team);
throw_error(B_SHUTDOWN_CANCELLED); throw_error(B_SHUTDOWN_CANCELLED);
@@ -1459,8 +1459,8 @@ ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
throw_error(error); throw_error(error);
if (!systemApps && event == ABORT_EVENT) { if (!systemApps && event == ABORT_EVENT) {
PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled by " PRINT("ShutdownProcess::_QuitApps(): shutdown cancelled by "
"team %ld (-1 => user)\n", team)); "team %ld (-1 => user)\n", team);
_DisplayAbortingApp(team); _DisplayAbortingApp(team);
throw_error(B_SHUTDOWN_CANCELLED); throw_error(B_SHUTDOWN_CANCELLED);
@@ -1488,7 +1488,7 @@ ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
} }
if (team < 0) { if (team < 0) {
PRINT(("ShutdownProcess::_QuitApps() done\n")); PRINT("ShutdownProcess::_QuitApps() done\n");
return; return;
} }
@@ -1499,8 +1499,8 @@ ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
_SetShutdownWindowCurrentApp(team); _SetShutdownWindowCurrentApp(team);
// send the shutdown message to the app // send the shutdown message to the app
PRINT((" sending team %ld (port: %ld) a shutdown message\n", team, PRINT(" sending team %ld (port: %ld) a shutdown message\n", team,
port)); port);
SingleMessagingTargetSet target(port, B_PREFERRED_TOKEN); SingleMessagingTargetSet target(port, B_PREFERRED_TOKEN);
MessageDeliverer::Default()->DeliverMessage(&message, target); MessageDeliverer::Default()->DeliverMessage(&message, target);
@@ -1533,7 +1533,7 @@ ShutdownProcess::_QuitApps(AppInfoList& list, bool systemApps)
void void
ShutdownProcess::_QuitBackgroundApps() ShutdownProcess::_QuitBackgroundApps()
{ {
PRINT(("ShutdownProcess::_QuitBackgroundApps()\n")); PRINT("ShutdownProcess::_QuitBackgroundApps()\n");
_SetShutdownWindowText( _SetShutdownWindowText(
B_TRANSLATE("Asking background applications to quit.")); B_TRANSLATE("Asking background applications to quit."));
@@ -1548,26 +1548,26 @@ ShutdownProcess::_QuitBackgroundApps()
AppInfoListMessagingTargetSet targetSet(fBackgroundApps); AppInfoListMessagingTargetSet targetSet(fBackgroundApps);
if (targetSet.HasNext()) { if (targetSet.HasNext()) {
PRINT((" sending shutdown message to %ld apps\n", PRINT(" sending shutdown message to %ld apps\n",
fBackgroundApps.CountInfos())); fBackgroundApps.CountInfos());
status_t error = MessageDeliverer::Default()->DeliverMessage( status_t error = MessageDeliverer::Default()->DeliverMessage(
&message, targetSet); &message, targetSet);
if (error != B_OK) { if (error != B_OK) {
WARNING(("_QuitBackgroundApps::_Worker(): Failed to deliver " WARNING("_QuitBackgroundApps::_Worker(): Failed to deliver "
"shutdown message to all applications: %s\n", "shutdown message to all applications: %s\n",
strerror(error))); strerror(error));
} }
} }
PRINT(("ShutdownProcess::_QuitBackgroundApps() done\n")); PRINT("ShutdownProcess::_QuitBackgroundApps() done\n");
} }
void void
ShutdownProcess::_WaitForBackgroundApps() ShutdownProcess::_WaitForBackgroundApps()
{ {
PRINT(("ShutdownProcess::_WaitForBackgroundApps()\n")); PRINT("ShutdownProcess::_WaitForBackgroundApps()\n");
// wait for user apps // wait for user apps
bool moreApps = true; bool moreApps = true;
@@ -1594,14 +1594,14 @@ ShutdownProcess::_WaitForBackgroundApps()
} }
} }
PRINT(("ShutdownProcess::_WaitForBackgroundApps() done\n")); PRINT("ShutdownProcess::_WaitForBackgroundApps() done\n");
} }
void void
ShutdownProcess::_KillBackgroundApps() ShutdownProcess::_KillBackgroundApps()
{ {
PRINT(("ShutdownProcess::_KillBackgroundApps()\n")); PRINT("ShutdownProcess::_KillBackgroundApps()\n");
while (true) { while (true) {
// eat events (we need to be responsive for an abort event) // eat events (we need to be responsive for an abort event)
@@ -1631,7 +1631,7 @@ ShutdownProcess::_KillBackgroundApps()
if (team < 0) { if (team < 0) {
PRINT(("ShutdownProcess::_KillBackgroundApps() done\n")); PRINT("ShutdownProcess::_KillBackgroundApps() done\n");
return; return;
} }
@@ -1645,7 +1645,7 @@ ShutdownProcess::_KillBackgroundApps()
void void
ShutdownProcess::_QuitNonApps() ShutdownProcess::_QuitNonApps()
{ {
PRINT(("ShutdownProcess::_QuitNonApps()\n")); PRINT("ShutdownProcess::_QuitNonApps()\n");
_SetShutdownWindowText(B_TRANSLATE("Asking other processes to quit.")); _SetShutdownWindowText(B_TRANSLATE("Asking other processes to quit."));
@@ -1654,7 +1654,7 @@ ShutdownProcess::_QuitNonApps()
team_info teamInfo; team_info teamInfo;
while (get_next_team_info(&cookie, &teamInfo) == B_OK) { while (get_next_team_info(&cookie, &teamInfo) == B_OK) {
if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) { if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) {
PRINT((" sending team %ld TERM signal\n", teamInfo.team)); PRINT(" sending team %ld TERM signal\n", teamInfo.team);
#ifdef __HAIKU__ #ifdef __HAIKU__
// Note: team ID == team main thread ID under Haiku // Note: team ID == team main thread ID under Haiku
@@ -1675,7 +1675,7 @@ ShutdownProcess::_QuitNonApps()
cookie = 0; cookie = 0;
while (get_next_team_info(&cookie, &teamInfo) == B_OK) { while (get_next_team_info(&cookie, &teamInfo) == B_OK) {
if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) { if (fVitalSystemApps.find(teamInfo.team) == fVitalSystemApps.end()) {
PRINT((" killing team %ld\n", teamInfo.team)); PRINT(" killing team %ld\n", teamInfo.team);
#ifdef __HAIKU__ #ifdef __HAIKU__
kill_team(teamInfo.team); kill_team(teamInfo.team);
@@ -1686,7 +1686,7 @@ ShutdownProcess::_QuitNonApps()
} }
} }
PRINT(("ShutdownProcess::_QuitNonApps() done\n")); PRINT("ShutdownProcess::_QuitNonApps() done\n");
} }
@@ -1735,8 +1735,8 @@ ShutdownProcess::_QuitBlockingApp(AppInfoList& list, team_id team,
if (event == ABORT_EVENT) { if (event == ABORT_EVENT) {
if (cancelAllowed || debugged) { if (cancelAllowed || debugged) {
PRINT(("ShutdownProcess::_QuitBlockingApp(): shutdown " PRINT("ShutdownProcess::_QuitBlockingApp(): shutdown "
"cancelled by team %ld (-1 => user)\n", eventTeam)); "cancelled by team %ld (-1 => user)\n", eventTeam);
if (!debugged) if (!debugged)
_DisplayAbortingApp(eventTeam); _DisplayAbortingApp(eventTeam);
@@ -1758,7 +1758,7 @@ ShutdownProcess::_QuitBlockingApp(AppInfoList& list, team_id team,
} }
// kill the app // kill the app
PRINT((" killing team %ld\n", team)); PRINT(" killing team %ld\n", team);
kill_team(team); kill_team(team);
@@ -1797,8 +1797,8 @@ ShutdownProcess::_DisplayAbortingApp(team_id team)
} }
if (!foundApp) { if (!foundApp) {
PRINT(("ShutdownProcess::_DisplayAbortingApp(): Didn't find the app " PRINT("ShutdownProcess::_DisplayAbortingApp(): Didn't find the app "
"that has cancelled the shutdown.\n")); "that has cancelled the shutdown.\n");
return; return;
} }
@@ -1842,14 +1842,14 @@ ShutdownProcess::_DisplayAbortingApp(team_id team)
void void
ShutdownProcess::_WaitForDebuggedTeams() ShutdownProcess::_WaitForDebuggedTeams()
{ {
PRINT(("ShutdownProcess::_WaitForDebuggedTeams()\n")); PRINT("ShutdownProcess::_WaitForDebuggedTeams()\n");
{ {
BAutolock _(fWorkerLock); BAutolock _(fWorkerLock);
if (fDebuggedTeams.empty()) if (fDebuggedTeams.empty())
return; return;
} }
PRINT((" not empty!\n")); PRINT(" not empty!\n");
// wait for something to happen // wait for something to happen
while (true) { while (true) {
@@ -1865,7 +1865,7 @@ ShutdownProcess::_WaitForDebuggedTeams()
BAutolock _(fWorkerLock); BAutolock _(fWorkerLock);
if (fDebuggedTeams.empty()) { if (fDebuggedTeams.empty()) {
PRINT((" out empty")); PRINT(" out empty");
return; return;
} }
} }
+36 -36
View File
@@ -185,8 +185,8 @@ TRoster::HandleAddApplication(BMessage* request)
if (request->FindBool("full_registration", &fullReg) != B_OK) if (request->FindBool("full_registration", &fullReg) != B_OK)
fullReg = false; fullReg = false;
PRINT(("team: %ld, signature: %s\n", team, signature)); PRINT("team: %ld, signature: %s\n", team, signature);
PRINT(("full registration: %d\n", fullReg)); PRINT("full registration: %d\n", fullReg);
if (fShuttingDown) if (fShuttingDown)
error = B_SHUTTING_DOWN; error = B_SHUTTING_DOWN;
@@ -205,8 +205,8 @@ TRoster::HandleAddApplication(BMessage* request)
// entry_ref // entry_ref
if (error == B_OK) { if (error == B_OK) {
PRINT(("flags: %lx\n", flags)); PRINT("flags: %lx\n", flags);
PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name)); PRINT("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name);
// check single/exclusive launchers // check single/exclusive launchers
RosterAppInfo* info = NULL; RosterAppInfo* info = NULL;
if ((launchFlags == B_SINGLE_LAUNCH if ((launchFlags == B_SINGLE_LAUNCH
@@ -255,15 +255,15 @@ TRoster::HandleAddApplication(BMessage* request)
// add it to the right list // add it to the right list
bool addingSuccess = false; bool addingSuccess = false;
if (team >= 0) { if (team >= 0) {
PRINT(("added ref: %ld, %lld, %s\n", info->ref.device, PRINT("added ref: %ld, %lld, %s\n", info->ref.device,
info->ref.directory, info->ref.name)); info->ref.directory, info->ref.name);
addingSuccess = (AddApp(info) == B_OK); addingSuccess = (AddApp(info) == B_OK);
if (addingSuccess && fullReg) if (addingSuccess && fullReg)
_AppAdded(info); _AppAdded(info);
} else { } else {
token = info->token = _NextToken(); token = info->token = _NextToken();
addingSuccess = fEarlyPreRegisteredApps.AddInfo(info); addingSuccess = fEarlyPreRegisteredApps.AddInfo(info);
PRINT(("added to early pre-regs, token: %lu\n", token)); PRINT("added to early pre-regs, token: %lu\n", token);
} }
if (!addingSuccess) if (!addingSuccess)
SET_ERROR(error, B_NO_MEMORY); SET_ERROR(error, B_NO_MEMORY);
@@ -387,8 +387,8 @@ TRoster::HandleIsAppRegistered(BMessage* request)
if (request->FindInt32("token", (int32*)&token) != B_OK) if (request->FindInt32("token", (int32*)&token) != B_OK)
token = 0; token = 0;
PRINT(("team: %ld, token: %lu\n", team, token)); PRINT("team: %ld, token: %lu\n", team, token);
PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name)); PRINT("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name);
// check the parameters // check the parameters
// entry_ref // entry_ref
@@ -402,24 +402,24 @@ TRoster::HandleIsAppRegistered(BMessage* request)
RosterAppInfo* info = NULL; RosterAppInfo* info = NULL;
if (error == B_OK) { if (error == B_OK) {
if ((info = fRegisteredApps.InfoFor(team)) != NULL) { if ((info = fRegisteredApps.InfoFor(team)) != NULL) {
PRINT(("found team in fRegisteredApps\n")); PRINT("found team in fRegisteredApps\n");
_ReplyToIARRequest(request, info); _ReplyToIARRequest(request, info);
} else if (token > 0 } else if (token > 0
&& (info = fEarlyPreRegisteredApps.InfoForToken(token)) != NULL) { && (info = fEarlyPreRegisteredApps.InfoForToken(token)) != NULL) {
PRINT(("found ref in fEarlyRegisteredApps (by token)\n")); PRINT("found ref in fEarlyRegisteredApps (by token)\n");
// pre-registered and has no team ID assigned yet -- queue the // pre-registered and has no team ID assigned yet -- queue the
// request // request
be_app->DetachCurrentMessage(); be_app->DetachCurrentMessage();
_AddIARRequest(fIARRequestsByToken, token, request); _AddIARRequest(fIARRequestsByToken, token, request);
} else if (team >= 0 } else if (team >= 0
&& (info = fEarlyPreRegisteredApps.InfoFor(&ref)) != NULL) { && (info = fEarlyPreRegisteredApps.InfoFor(&ref)) != NULL) {
PRINT(("found ref in fEarlyRegisteredApps (by ref)\n")); PRINT("found ref in fEarlyRegisteredApps (by ref)\n");
// pre-registered and has no team ID assigned yet -- queue the // pre-registered and has no team ID assigned yet -- queue the
// request // request
be_app->DetachCurrentMessage(); be_app->DetachCurrentMessage();
_AddIARRequest(fIARRequestsByID, team, request); _AddIARRequest(fIARRequestsByID, team, request);
} else { } else {
PRINT(("didn't find team or ref\n")); PRINT("didn't find team or ref\n");
// team not registered, ref/token not early pre-registered // team not registered, ref/token not early pre-registered
_ReplyToIARRequest(request, NULL); _ReplyToIARRequest(request, NULL);
} }
@@ -488,7 +488,7 @@ TRoster::HandleRemoveApp(BMessage* request)
if (request->FindInt32("team", &team) != B_OK) if (request->FindInt32("team", &team) != B_OK)
team = -1; team = -1;
PRINT(("team: %ld\n", team)); PRINT("team: %ld\n", team);
// remove the app // remove the app
if (error == B_OK) { if (error == B_OK) {
@@ -540,7 +540,7 @@ TRoster::HandleSetThreadAndTeam(BMessage* request)
if (error == B_OK && team < 0) if (error == B_OK && team < 0)
SET_ERROR(error, B_BAD_VALUE); SET_ERROR(error, B_BAD_VALUE);
PRINT(("team: %ld, thread: %ld, token: %lu\n", team, thread, token)); PRINT("team: %ld, thread: %ld, token: %lu\n", team, thread, token);
// update the app_info // update the app_info
if (error == B_OK) { if (error == B_OK) {
@@ -669,11 +669,11 @@ TRoster::HandleGetAppInfo(BMessage* request)
hasSignature = false; hasSignature = false;
if (hasTeam) if (hasTeam)
PRINT(("team: %ld\n", team)); PRINT("team: %ld\n", team);
if (hasRef) if (hasRef)
PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name)); PRINT("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name);
if (hasSignature) if (hasSignature)
PRINT(("signature: %s\n", signature)); PRINT("signature: %s\n", signature);
// get the info // get the info
RosterAppInfo* info = NULL; RosterAppInfo* info = NULL;
@@ -985,7 +985,7 @@ TRoster::HandleGetRecentApps(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleGetRecentApps(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleGetRecentApps(NULL) called\n"));
return; return;
} }
@@ -1013,7 +1013,7 @@ TRoster::HandleAddToRecentDocuments(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleAddToRecentDocuments(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleAddToRecentDocuments(NULL) called\n"));
return; return;
} }
@@ -1044,7 +1044,7 @@ TRoster::HandleAddToRecentFolders(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleAddToRecentFolders(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleAddToRecentFolders(NULL) called\n"));
return; return;
} }
@@ -1075,7 +1075,7 @@ TRoster::HandleAddToRecentApps(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleAddToRecentApps(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleAddToRecentApps(NULL) called\n"));
return; return;
} }
@@ -1100,7 +1100,7 @@ TRoster::HandleLoadRecentLists(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleLoadRecentLists(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleLoadRecentLists(NULL) called\n"));
return; return;
} }
@@ -1125,7 +1125,7 @@ TRoster::HandleSaveRecentLists(BMessage* request)
BAutolock _(fLock); BAutolock _(fLock);
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleSaveRecentLists(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleSaveRecentLists(NULL) called\n"));
return; return;
} }
@@ -1687,7 +1687,7 @@ TRoster::_ReplyToIARRequest(BMessage* request, const RosterAppInfo* info)
BMessage reply(B_REG_SUCCESS); BMessage reply(B_REG_SUCCESS);
reply.AddBool("registered", (bool)info); reply.AddBool("registered", (bool)info);
reply.AddBool("pre-registered", preRegistered); reply.AddBool("pre-registered", preRegistered);
PRINT(("_ReplyToIARRequest(): pre-registered: %d\n", preRegistered)); PRINT("_ReplyToIARRequest(): pre-registered: %d\n", preRegistered);
if (info) if (info)
_AddMessageAppInfo(&reply, info); _AddMessageAppInfo(&reply, info);
request->SendReply(&reply); request->SendReply(&reply);
@@ -1702,7 +1702,7 @@ TRoster::_HandleGetRecentEntries(BMessage* request)
{ {
FUNCTION_START(); FUNCTION_START();
if (!request) { if (!request) {
D(PRINT(("WARNING: TRoster::HandleGetRecentFolders(NULL) called\n"))); D(PRINT("WARNING: TRoster::HandleGetRecentFolders(NULL) called\n"));
return; return;
} }
@@ -1763,9 +1763,9 @@ TRoster::_HandleGetRecentEntries(BMessage* request)
break; break;
default: default:
D(PRINT(("WARNING: TRoster::_HandleGetRecentEntries(): " D(PRINT("WARNING: TRoster::_HandleGetRecentEntries(): "
"unexpected request->what value of 0x%lx\n", "unexpected request->what value of 0x%lx\n",
request->what))); request->what));
error = B_BAD_VALUE; error = B_BAD_VALUE;
break; break;
} }
@@ -1984,8 +1984,8 @@ TRoster::_LoadRosterSettings(const char* path)
); );
} }
if (error) { if (error) {
D(PRINT(("WARNING: TRoster::_LoadRosterSettings(): error loading roster " D(PRINT("WARNING: TRoster::_LoadRosterSettings(): error loading roster "
"settings from '%s', 0x%lx\n", settingsPath, error))); "settings from '%s', 0x%lx\n", settingsPath, error));
} }
return error; return error;
} }
@@ -2007,18 +2007,18 @@ TRoster::_SaveRosterSettings(const char* path)
status_t saveError; status_t saveError;
saveError = fRecentDocuments.Save(file, "Recent documents", "RecentDoc"); saveError = fRecentDocuments.Save(file, "Recent documents", "RecentDoc");
if (saveError) { if (saveError) {
D(PRINT(("TRoster::_SaveRosterSettings(): recent documents save " D(PRINT("TRoster::_SaveRosterSettings(): recent documents save "
"failed with error 0x%lx\n", saveError))); "failed with error 0x%lx\n", saveError));
} }
saveError = fRecentFolders.Save(file, "Recent folders", "RecentFolder"); saveError = fRecentFolders.Save(file, "Recent folders", "RecentFolder");
if (saveError) { if (saveError) {
D(PRINT(("TRoster::_SaveRosterSettings(): recent folders save " D(PRINT("TRoster::_SaveRosterSettings(): recent folders save "
"failed with error 0x%lx\n", saveError))); "failed with error 0x%lx\n", saveError));
} }
saveError = fRecentApps.Save(file); saveError = fRecentApps.Save(file);
if (saveError) { if (saveError) {
D(PRINT(("TRoster::_SaveRosterSettings(): recent folders save " D(PRINT("TRoster::_SaveRosterSettings(): recent folders save "
"failed with error 0x%lx\n", saveError))); "failed with error 0x%lx\n", saveError));
} }
fclose(file); fclose(file);
} }