Problem with ManagerAPI events following a Parked Call Event

After I have upgraded to Asterisk 1.2.1 I have been receiving this odd behavior regarding events.
Any event following a ParkedCall or a ParkedCallGiveUp event will be pre-pended with a \r\n. I am trying to locate the origin of these events in the source code but haven’t been successful thus far. It seems to be in the features.c file but I have found only the features.h file and cannot locate the features.c file.

Anyone have noticed the same behavior or knows where the features.c file is loacted at? A whereis features.c at the terminal prompt only show features.h.


Actually any of the Parked call related events has this behavior. I have also located the features.c, it is actually called res_features.c and is located in the asterisk.res directory.

I looked at the file and it looks fine to me, with my little C knowledge :smile:. For a test I created an app where the socket connection just sits there and read until it finds a /r/n/r/n and then it logs it. And any event after any of the parked call related events have a /r/n infront of it. Maybe it is a bug, can someone else confirm the same?

Yep it is a bug in the res_feature.c file. Every where the manger_event is called it has /r/n/r/n at the end where as in other files it only has /r/n because the manager_event method in the manager.c appends the last /r/n.

Here is the code from res_features.c:

manager_event(EVENT_FLAG_CALL, “ParkedCall”,
“Exten: %d\r\n”
“Channel: %s\r\n”
“From: %s\r\n”
“Timeout: %ld\r\n”
“CallerID: %s\r\n”
“CallerIDName: %s\r\n\r\n” <== 2 /r/n

Here is the code from manager.c where it is calling the same method:
“Channel: %s/%s\r\n”
“Context: %s\r\n”
“Exten: %s\r\n”
“Reason: %d\r\n”
“Uniqueid: %s\r\n”, <== only one /r/n

And here is the code of the method showing it is appending the /r/n:

/*! \brief manager_event: Send AMI event to client */
int manager_event(int category, char *event, char *fmt, …)
struct mansession *s;
char auth[80];
char tmp[4096] = “”;
char *tmp_next = tmp;
size_t tmp_left = sizeof(tmp) - 2;
va_list ap;

for (s = sessions; s; s = s->next) {
	if ((s->readperm & category) != category)

	if ((s->send_events & category) != category)

	if (ast_strlen_zero(tmp)) {
		ast_build_string(&tmp_next, &tmp_left, "Event: %s\r\nPrivilege: %s\r\n",
				 event, authority_to_str(category, auth, sizeof(auth)));
		va_start(ap, fmt);
		ast_build_string_va(&tmp_next, &tmp_left, fmt, ap);
		*tmp_next++ = '\r';
		*tmp_next++ = '\n';       <====appending the last /r/n
		*tmp_next = '\0';

I will log an issue.