Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
98cbc0ea
Commit
98cbc0ea
authored
Apr 08, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
event/TimeoutMonitor: eliminate support for periodic events
No caller needs this. Fixes use-after-free after returning from Client::OnTimeout().
parent
dca11151
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
27 deletions
+17
-27
ClientExpire.cxx
src/ClientExpire.cxx
+1
-2
ClientInternal.hxx
src/ClientInternal.hxx
+1
-1
InotifyQueue.cxx
src/InotifyQueue.cxx
+5
-6
InotifyQueue.hxx
src/InotifyQueue.hxx
+1
-1
StateFile.cxx
src/StateFile.cxx
+1
-2
StateFile.hxx
src/StateFile.hxx
+1
-1
TimeoutMonitor.cxx
src/event/TimeoutMonitor.cxx
+5
-9
TimeoutMonitor.hxx
src/event/TimeoutMonitor.hxx
+2
-5
No files found.
src/ClientExpire.cxx
View file @
98cbc0ea
...
...
@@ -30,7 +30,7 @@ Client::SetExpired()
TimeoutMonitor
::
Schedule
(
0
);
}
bool
void
Client
::
OnTimeout
()
{
if
(
!
IsExpired
())
{
...
...
@@ -39,5 +39,4 @@ Client::OnTimeout()
}
Close
();
return
false
;
}
src/ClientInternal.hxx
View file @
98cbc0ea
...
...
@@ -120,7 +120,7 @@ private:
virtual
void
OnSocketClosed
()
override
;
/* virtual methods from class TimeoutMonitor */
virtual
bool
OnTimeout
()
override
;
virtual
void
OnTimeout
()
override
;
};
extern
int
client_timeout
;
...
...
src/InotifyQueue.cxx
View file @
98cbc0ea
...
...
@@ -38,7 +38,7 @@ enum {
INOTIFY_UPDATE_DELAY_S
=
5
,
};
bool
void
InotifyQueue
::
OnTimeout
()
{
unsigned
id
;
...
...
@@ -47,17 +47,16 @@ InotifyQueue::OnTimeout()
const
char
*
uri_utf8
=
queue
.
front
().
c_str
();
id
=
update_enqueue
(
uri_utf8
,
false
);
if
(
id
==
0
)
if
(
id
==
0
)
{
/* retry later */
return
true
;
ScheduleSeconds
(
INOTIFY_UPDATE_DELAY_S
);
return
;
}
g_debug
(
"updating '%s' job=%u"
,
uri_utf8
,
id
);
queue
.
pop_front
();
}
/* done, remove the timer event by returning false */
return
false
;
}
static
bool
...
...
src/InotifyQueue.hxx
View file @
98cbc0ea
...
...
@@ -35,7 +35,7 @@ public:
void
Enqueue
(
const
char
*
uri_utf8
);
private
:
virtual
bool
OnTimeout
()
override
;
virtual
void
OnTimeout
()
override
;
};
#endif
src/StateFile.cxx
View file @
98cbc0ea
...
...
@@ -116,9 +116,8 @@ StateFile::CheckModified()
ScheduleSeconds
(
2
*
60
);
}
bool
void
StateFile
::
OnTimeout
()
{
Write
();
return
false
;
}
src/StateFile.hxx
View file @
98cbc0ea
...
...
@@ -67,7 +67,7 @@ private:
bool
IsModified
()
const
;
/* virtual methods from TimeoutMonitor */
virtual
bool
OnTimeout
()
override
;
virtual
void
OnTimeout
()
override
;
};
#endif
/* STATE_FILE_H */
src/event/TimeoutMonitor.cxx
View file @
98cbc0ea
...
...
@@ -45,21 +45,17 @@ TimeoutMonitor::ScheduleSeconds(unsigned s)
source
=
loop
.
AddTimeoutSeconds
(
s
,
Callback
,
this
);
}
bool
void
TimeoutMonitor
::
Run
()
{
bool
result
=
OnTimeout
();
if
(
!
result
&&
source
!=
nullptr
)
{
g_source_unref
(
source
);
source
=
nullptr
;
}
return
result
;
Cancel
();
OnTimeout
();
}
gboolean
TimeoutMonitor
::
Callback
(
gpointer
data
)
{
TimeoutMonitor
&
monitor
=
*
(
TimeoutMonitor
*
)
data
;
return
monitor
.
Run
();
monitor
.
Run
();
return
false
;
}
src/event/TimeoutMonitor.hxx
View file @
98cbc0ea
...
...
@@ -47,13 +47,10 @@ public:
void
Cancel
();
protected
:
/**
* @return true reschedules the timeout again
*/
virtual
bool
OnTimeout
()
=
0
;
virtual
void
OnTimeout
()
=
0
;
private
:
bool
Run
();
void
Run
();
static
gboolean
Callback
(
gpointer
data
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment