Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoryfixes and unlink() instead of system() #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UMTS/UMTSRadioModem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ void RadioModem::transmitSlot(UMTS::Time nowTime, bool &underrun)

// write to the socket
mDataSocket.write(buffer,bufferSize);
delete []buffer;
free(buffer);

mLastTransmitTime = nowTime;
//LOG(INFO) << LOGVAR(mLastTransmitTime) <<LOGVAR2("clock.FN",gNodeB.clock().FN());
Expand Down
15 changes: 10 additions & 5 deletions apps/OpenBTS-UMTS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ConfigurationTable gConfig("/etc/OpenBTS/OpenBTS-UMTS.db","OpenBTS-UMTS", getCon
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <errno.h>

#ifdef HAVE_LIBREADLINE // [
//# include <stdio.h>
Expand Down Expand Up @@ -260,11 +261,15 @@ int main(int argc, char *argv[])

struct sockaddr_un cmdSockName;
cmdSockName.sun_family = AF_UNIX;
const char* sockpath = gConfig.getStr("CLI.SocketPath").c_str();
char rmcmd[strlen(sockpath)+5];
sprintf(rmcmd,"rm -f %s",sockpath);
if (system(rmcmd)) {} // The 'if' shuts up gcc warnings.
strcpy(cmdSockName.sun_path,sockpath);
const string sockpath = gConfig.getStr("CLI.SocketPath");
int rc = unlink(sockpath.c_str());
if (rc == -1) {
// If it does not exist just move on, otherwise say something
if (errno != ENOENT) {
LOG(ALERT) << "Cannot delete CLI sock file, error: " << strerror(errno);
}
}
strcpy(cmdSockName.sun_path,sockpath.c_str());
LOG(INFO) "binding CLI datagram socket at " << sockpath;
if (bind(sock, (struct sockaddr *) &cmdSockName, sizeof(struct sockaddr_un))) {
perror("binding name to cmd datagram socket");
Expand Down