Diffstat (limited to 'libopie2/opiecore/ofilenotify.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/ofilenotify.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiecore/ofilenotify.cpp b/libopie2/opiecore/ofilenotify.cpp index b576c4f..2a9bb8c 100644 --- a/libopie2/opiecore/ofilenotify.cpp +++ b/libopie2/opiecore/ofilenotify.cpp | |||
@@ -204,96 +204,98 @@ bool OFileNotification::hasChanged() | |||
204 | 204 | ||
205 | qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno ); | 205 | qDebug( "result of newstat call is %d (%s=%d)", result, result == -1 ? strerror( errno ) : "success", errno ); |
206 | qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime ); | 206 | qDebug( "stat.atime = %0lx, newstat.atime = %0lx", (long)_stat.st_atime, (long)newstat.st_atime ); |
207 | qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime ); | 207 | qDebug( "stat.mtime = %0lx, newstat.mtime = %0lx", (long)_stat.st_mtime, (long)newstat.st_mtime ); |
208 | qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime ); | 208 | qDebug( "stat.ctime = %0lx, newstat.ctime = %0lx", (long)_stat.st_ctime, (long)newstat.st_ctime ); |
209 | 209 | ||
210 | if ( !c && (_type & Create) && | 210 | if ( !c && (_type & Create) && |
211 | (long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 && | 211 | (long)_stat.st_atime == 0 && (long)_stat.st_mtime == 0 && (long)_stat.st_ctime == 0 && |
212 | (long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0) | 212 | (long)newstat.st_atime > 0 && (long)newstat.st_mtime > 0 && (long)newstat.st_ctime > 0) |
213 | { | 213 | { |
214 | qDebug( "OFileNotification::hasChanged(): file has been created" ); | 214 | qDebug( "OFileNotification::hasChanged(): file has been created" ); |
215 | c = true; | 215 | c = true; |
216 | } | 216 | } |
217 | if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0) | 217 | if ( !c && (_type & (Delete|Rename)) && (long)newstat.st_atime == 0 && (long)newstat.st_mtime == 0 && (long)newstat.st_ctime == 0) |
218 | { | 218 | { |
219 | qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" ); | 219 | qDebug( "OFileNotification::hasChanged(): file has been deleted or renamed" ); |
220 | c = true; | 220 | c = true; |
221 | } | 221 | } |
222 | if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime ) | 222 | if ( !c && (_type & Access) && (long)_stat.st_atime < (long)newstat.st_atime ) |
223 | { | 223 | { |
224 | qDebug( "OFileNotification::hasChanged(): atime changed" ); | 224 | qDebug( "OFileNotification::hasChanged(): atime changed" ); |
225 | c = true; | 225 | c = true; |
226 | } | 226 | } |
227 | if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime ) | 227 | if ( !c && (_type & Modify) && (long)_stat.st_mtime < (long)newstat.st_mtime ) |
228 | { | 228 | { |
229 | qDebug( "OFileNotification::hasChanged(): mtime changed" ); | 229 | qDebug( "OFileNotification::hasChanged(): mtime changed" ); |
230 | c = true; | 230 | c = true; |
231 | } | 231 | } |
232 | if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime ) | 232 | if ( !c && (_type & Attrib) && (long)_stat.st_ctime < (long)newstat.st_ctime ) |
233 | { | 233 | { |
234 | qDebug( "OFileNotification::hasChanged(): ctime changed" ); | 234 | qDebug( "OFileNotification::hasChanged(): ctime changed" ); |
235 | c = true; | 235 | c = true; |
236 | } | 236 | } |
237 | 237 | ||
238 | return c; | 238 | return c; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) | 242 | void OFileNotification::singleShot( const QString& path, QObject* receiver, const char* member, OFileNotificationType type ) |
243 | { | 243 | { |
244 | OFileNotification* ofn = new OFileNotification(); | 244 | OFileNotification* ofn = new OFileNotification(); |
245 | ofn->_signal.connect( receiver, member ); | 245 | ofn->_signal.connect( receiver, member ); |
246 | ofn->start( path, true, type ); | 246 | ofn->start( path, true, type ); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data ) | 250 | void OFileNotification::__signalHandler( int sig, siginfo_t *si, void *data ) |
251 | { | 251 | { |
252 | Q_UNUSED( sig ) | ||
253 | Q_UNUSED( data ) | ||
252 | qWarning( "OFileNotification::__signalHandler(): reached." ); | 254 | qWarning( "OFileNotification::__signalHandler(): reached." ); |
253 | int fd = si->si_fd; | 255 | int fd = si->si_fd; |
254 | OFileNotification* fn = notification_list[fd]; | 256 | OFileNotification* fn = notification_list[fd]; |
255 | if ( fn ) | 257 | if ( fn ) |
256 | { | 258 | { |
257 | // check if it really was the file (dnotify triggers on directory granularity, not file granularity) | 259 | // check if it really was the file (dnotify triggers on directory granularity, not file granularity) |
258 | if ( !fn->activate() ) | 260 | if ( !fn->activate() ) |
259 | { | 261 | { |
260 | qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." ); | 262 | qDebug( "OFileNotification::__signalHandler(): false alarm ;) Restarting the trigger (if it was single)..." ); |
261 | if ( !(fn->type() & Multi ) ) | 263 | if ( !(fn->type() & Multi ) ) |
262 | { | 264 | { |
263 | int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() ); | 265 | int result = ::fcntl( fn->fileno(), F_NOTIFY, fn->type() ); |
264 | if ( result == -1 ) | 266 | if ( result == -1 ) |
265 | { | 267 | { |
266 | qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) ); | 268 | qWarning( "OFileNotification::__signalHandler(): Can't restart the trigger: %s.", strerror( errno ) ); |
267 | } | 269 | } |
268 | } | 270 | } |
269 | return; | 271 | return; |
270 | } | 272 | } |
271 | #if 1 | 273 | #if 1 |
272 | if ( !(fn->type() & Multi) ) | 274 | if ( !(fn->type() & Multi) ) |
273 | { | 275 | { |
274 | qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd ); | 276 | qDebug( "OFileNotification::__signalHandler(): '%d' was singleShot. Removing from list.", fd ); |
275 | notification_list.remove( fd ); | 277 | notification_list.remove( fd ); |
276 | if ( notification_list.isEmpty() ) | 278 | if ( notification_list.isEmpty() ) |
277 | { | 279 | { |
278 | OFileNotification::unregisterSignalHandler(); | 280 | OFileNotification::unregisterSignalHandler(); |
279 | } | 281 | } |
280 | } | 282 | } |
281 | #endif | 283 | #endif |
282 | } | 284 | } |
283 | else | 285 | else |
284 | { | 286 | { |
285 | qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" ); | 287 | qWarning( "OFileNotification::__signalHandler(): D'oh! Called without fd in notification_list. Race condition?" ); |
286 | } | 288 | } |
287 | } | 289 | } |
288 | 290 | ||
289 | 291 | ||
290 | bool OFileNotification::registerSignalHandler() | 292 | bool OFileNotification::registerSignalHandler() |
291 | { | 293 | { |
292 | struct sigaction act; | 294 | struct sigaction act; |
293 | act.sa_sigaction = OFileNotification::__signalHandler; | 295 | act.sa_sigaction = OFileNotification::__signalHandler; |
294 | ::sigemptyset( &act.sa_mask ); | 296 | ::sigemptyset( &act.sa_mask ); |
295 | act.sa_flags = SA_SIGINFO; | 297 | act.sa_flags = SA_SIGINFO; |
296 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) | 298 | if ( ::sigaction( SIGRTMIN, &act, NULL ) == -1 ) |
297 | { | 299 | { |
298 | qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) ); | 300 | qWarning( "OFileNotification::registerSignalHandler(): couldn't register signal handler: %s", strerror( errno ) ); |
299 | return false; | 301 | return false; |