mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Merge #3637
3637: Remove fifo file on shutdown r=heinrich5991 a=def- Helps with the official servers. ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
0c1f4cbad4
|
@ -19,36 +19,40 @@ void CFifo::Init(IConsole *pConsole, char *pFifoFile, int Flag)
|
||||||
if(pFifoFile[0] == '\0')
|
if(pFifoFile[0] == '\0')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
str_copy(m_aFilename, pFifoFile, sizeof(m_aFilename));
|
||||||
m_Flag = Flag;
|
m_Flag = Flag;
|
||||||
|
|
||||||
mkfifo(pFifoFile, 0600);
|
mkfifo(m_aFilename, 0600);
|
||||||
|
|
||||||
struct stat Attribute;
|
struct stat Attribute;
|
||||||
stat(pFifoFile, &Attribute);
|
stat(m_aFilename, &Attribute);
|
||||||
|
|
||||||
if(!S_ISFIFO(Attribute.st_mode))
|
if(!S_ISFIFO(Attribute.st_mode))
|
||||||
{
|
{
|
||||||
dbg_msg("fifo", "'%s' is not a fifo, removing", pFifoFile);
|
dbg_msg("fifo", "'%s' is not a fifo, removing", m_aFilename);
|
||||||
fs_remove(pFifoFile);
|
fs_remove(m_aFilename);
|
||||||
mkfifo(pFifoFile, 0600);
|
mkfifo(m_aFilename, 0600);
|
||||||
stat(pFifoFile, &Attribute);
|
stat(m_aFilename, &Attribute);
|
||||||
|
|
||||||
if(!S_ISFIFO(Attribute.st_mode))
|
if(!S_ISFIFO(Attribute.st_mode))
|
||||||
{
|
{
|
||||||
dbg_msg("fifo", "can't remove file '%s', quitting", pFifoFile);
|
dbg_msg("fifo", "can't remove file '%s', quitting", m_aFilename);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_File = open(pFifoFile, O_RDONLY | O_NONBLOCK);
|
m_File = open(m_aFilename, O_RDONLY | O_NONBLOCK);
|
||||||
if(m_File < 0)
|
if(m_File < 0)
|
||||||
dbg_msg("fifo", "can't open file '%s'", pFifoFile);
|
dbg_msg("fifo", "can't open file '%s'", m_aFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFifo::Shutdown()
|
void CFifo::Shutdown()
|
||||||
{
|
{
|
||||||
if(m_File >= 0)
|
if(m_File >= 0)
|
||||||
|
{
|
||||||
close(m_File);
|
close(m_File);
|
||||||
|
fs_remove(m_aFilename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFifo::Update()
|
void CFifo::Update()
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
class CFifo
|
class CFifo
|
||||||
{
|
{
|
||||||
IConsole *m_pConsole;
|
IConsole *m_pConsole;
|
||||||
|
char m_aFilename[MAX_PATH_LENGTH];
|
||||||
int m_Flag;
|
int m_Flag;
|
||||||
int m_File;
|
int m_File;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue