Commit Graph

158 Commits

Author SHA1 Message Date
MrDave
e4b5627a70 Revert to standard os file buffering 2016-09-03 11:44:36 -06:00
Mr Dave
bc7298aa32 Revise Sqlite3 into code standard 2015-09-13 13:52:40 -06:00
Mr Dave
3c98e1deec Merge branch 'sqlite-patch' of https://github.com/jdodgen/motion into jdodgen-sqlite-patch 2015-08-26 22:48:25 -06:00
Mr Dave
03f54ccc89 Merge branch 'unstable' of https://github.com/dfries/motion into dfries-unstable 2015-08-26 19:24:10 -06:00
David Fries
12433edb3f add ffmpeg_duplicate_frames option
This lets the user decide which video problems they would rather see.
In my case a Raspberry Pi 2 with a 640x480 webcam sometimes can keep
up with 10fps so I don't want to set the framerate any lower, but
then sometimes it can't and with duplicate frames it looks like the
video output freezes every second.
2015-08-23 16:50:47 -05:00
David Fries
a3104af8d0 accept a width specifier to mystrftime
Allow the user to specify field widths to keep the strings from
jumping around as the width changes.  This makes the values easier
to read.
2015-08-23 16:50:47 -05:00
David Fries
37360d858d fix dangling pointer cnt->current_image after resize
cnt->current_image because a dangling pointer after image_ring_resize
because it is pointing to cnt->imgs.image_ring which is reallocated in
that routine.  motion_loop will then store cnt->current_image in
old_image which it can then read from.

Reallocations are rare, once in init to size 1, then once to the final
size.  I apparently have a bad USB link and I was seeing a crash
pointing to bad data, after that camera started, then had an error and
crashed in process_image_ring(cnt, IMAGE_BUFFER_FLUSH);
it hadn't yet resized to the normal ring buffer size.  That got me
trying valgrind with a ring buffer size limit of 1 which found this
bug.
2015-08-23 16:50:47 -05:00
David Fries
ea7e94863a get the thread out of the xioctl loop
As long as errno is EINTR (and that must be the case when the USB
device is still there, but the transfers are failing), the thread
keeps looping running the ioctl when it isn't going to succeed, so
give it access to the finish variable to only loop if the thread isn't
supposed to be going away, and then keep sendig SIGVTALRM to break out
of the ioctl when the thread is supposed to be exiting.  With this fix
the webcam was no longer crashing, which let the webcam without a
problem continue to stream.
2015-08-23 16:50:47 -05:00
David Fries
bbd2f3f813 redo watchdog termination logic, wait for the thread to cleanup
I apparently have some marginal USB hardware and motion has been
crashing every couple of days in the memcpy at the end of alg.c as
both cnt->imgs.ref and cnt->imgs.image_virgin were NULL pointers.
This was just after the main thread watchdog timer called
pthread_cancel on that thread.  The problem is pthread_cancel can't
possibly kill a thread running on another CPU atomically, although in
this case it's a single core processor and I think pthread_cancel was
releasing it from the ioctl and it would then run to completition.

This modifies the code to not cleanup that content's resources until
that thread is no longer running.  If it runs to completition a normal
restart will happen, if it doesn't the main thread will check once a
second until it no longer is running, cleanup and restart, but it
can't cleanup with that thread running.
2015-08-23 16:50:47 -05:00
David Fries
bab15abfee count webcontrol as a thread to avoid a crash
On a SIGHUP restart the main thread waits to restart until all worker
threads are finished executing, except webcontrol wasn't included.
If it was still running (such as reading a web request), it would
have a dangling context pointer after cnt_list was freed leading to a
crash.  This counts that thread in the running threads, as a
termination webcontrol_finish variable to terminate it indepdent of
the device thread, and creates a webcontrol_running to identify when
it is running.
2015-08-23 16:50:47 -05:00
David Fries
0629d9db61 set motion capture thread running in the main thread
I identified this while debugging, the thread was created, but hadn't
yet set its state to running before the main thread checked the running
variable and started another thread for the same device.  That
resulted in a crash.  Set running in the main thread, to avoid this
race condition.
2015-08-23 16:50:47 -05:00
David Fries
cf88e025ab typo fix, unused variable cleanup, etc
motion.c bad spelling, to "an image"
webhttpd.c consolidate the timeout to the top of the file as I needed
to change it for testing
2015-08-23 16:50:47 -05:00
jdodgen
5eb3da4050 Fixed mull pointer causing segfault 2015-08-21 09:25:51 -07:00
jdodgen
72aef1fb65 Added ifdef around shared sqlite handle assignment 2015-06-10 14:50:38 -07:00
jdodgen
2441720023 More sqlite changes, now using threaded serial option if sqlite is configured for threads 2015-05-20 11:44:10 -07:00
jdodgen
152be1ec47 Seemed to have lost a few of my changes during my breakapart of patches
Also some formating (tab to spaces) fixes were done
2015-05-19 12:04:55 -07:00
jdodgen
c045c428ca Remove tabs 2015-05-18 14:14:36 -07:00
jdodgen
cc49c75d22 Sqlite3 changes - use local sqlite3.c if found. new option to set busy_timeout (wait on locked condition) 2015-05-11 16:20:38 -07:00
Mr Dave
d71cebf8e8 Fix FTP option 2015-03-20 00:12:51 -06:00
Stuart Henderson
dcbd514147 forward definition for setup_signals(), needed on OpenBSD 2014-10-23 13:29:30 +01:00
Alfred Klomp
a36801e6dd free(): remove unnecessary NULL pointer checks
Calling free() on a NULL pointer is a completely harmless. Reduce code
complexity by removing the unnecessary checks.
2014-10-15 23:46:37 +02:00
Alfred Klomp
f7e0830978 mymalloc sets allocated memory to zero; no need for extra memset 2014-10-15 21:59:46 +02:00
Alfred Klomp
ccdeee0073 mymalloc(): don't cast return value; void* is always promoted 2014-10-15 21:59:38 +02:00
Alfred Klomp
d0cc56c733 bugfix: motion.c: calculate proper allocation size
The proper idiom for calculating the size for memory allocation is:

  ptr = malloc(sizeof(*ptr));

The sizeof() dereferences the pointer's type, and allocates enough
memory to store an instance of that type. motion.c was using this idiom:

  ptr = malloc(sizeof(ptr));

This is incorrect, but thankfully fairly harmless in practice since the
pointer type is usually quite large. Change this to the proper idiom.
2014-10-06 23:46:34 +02:00
Alfred Klomp
95c6a9fd29 Bugfix: calculate proper size for memset()
The proper idiom is:

  memset(ptr, val, sizeof(*ptr));

These files were using:

  memset(ptr, val, sizeof(ptr));
2014-10-06 23:46:34 +02:00
Mr Dave
b6f73ffccb Timelapse fixes and bump version 2014-10-05 05:31:47 -07:00
Mr Dave
f880807aea Clean up ffmpeg.c and plug memory leak 2014-09-25 19:18:45 -07:00
MrDave
a869057374 Recommit changes from tosiara commit 9ebee031 2014-09-06 08:51:43 -07:00
MrDave
fbabd5d5fb Rollback memset to allow for formal pull. 2014-09-06 07:48:36 -07:00
Dave
048791e449 Merge tosiara/rtsp branch (commit 46cfcf31d, 2014/05/21) 2014-06-13 19:52:34 -06:00
Angel Carpintero
fcdd331036 - Allow image dimension not 4:3 changing a check of modulo 16 by modulo 8.
- Free file descriptor buffers on exit.
2012-01-24 11:23:32 +01:00
Angel Carpintero
05b815771a - Added a new starting option -m to disable motion detection
- Fixed configure for SDL
- Little fix in logging because was broken
- Replaced malloc by calloc in mymalloc()
2012-01-01 20:07:17 +01:00
Angel Carpintero
2efcf1bb61 * Added new log type COR , to filter messages from CORE.
* Fixed a bug in post_capture. It was missed under certain conditions.
2011-11-27 20:24:09 +01:00
Angel Carpintero
48b9b3f938 * Made micro-lightswitch optional (see lightwitch option in motion.conf)
* Fixed help text for options event_gap and area_detect
 * Fixed motion.conf-dist , adding text according with config options.
2011-11-19 11:06:03 +01:00
Angel Carpintero
944d1ee5ad Fixing some minor warnings , added some log messages. 2011-11-02 04:05:57 +01:00
Angel Carpintero
015d497d05 Workaround to let work with kernel 2.6.38 and above where videodev.h has been removed. 2011-05-09 19:23:55 +02:00
Angel Carpintero
e002c0b1be Added Exif feature
http://www.lavrsen.dk/foswiki/bin/view/Motion/ExifTaggingPatch
2011-02-21 13:23:55 +01:00
Angel Carpintero
a6b6116444 Avoid segfault when no database_type is set. 2011-02-16 02:41:31 +01:00
Angel Carpintero
e3bb21d4e0 * Input for webcams has to be set to -1 http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2011x01x21x162309
* Postgresql close.
2011-02-03 16:53:25 +01:00
Angel Carpintero
6d1ce19e62 No mysql_close()
http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x11x22x033859
2010-12-05 17:09:03 +01:00
Angel Carpintero
1ffbc17f4e SDL support 2010-09-19 17:42:03 +02:00
Angel Carpintero
d8063fb1df - Change default log level to 6 / NTC
- Reviewed log levels to make motion less verbose and move most of them to NTC level.
2010-05-23 00:01:05 +02:00
gstreamer
d9dfccf0ac http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x28x054348 from 3.2 branch 2010-05-02 16:29:04 +02:00
AngelCarpintero
0d1af31348 http://www.lavrsen.dk/foswiki/bin/view/Motion/BugReport2010x04x06x014526 2010-04-06 23:56:11 +00:00
AngelCarpintero
3e53086a81 fix spelling and code standard compliant 2010-04-05 18:35:19 +00:00
AngelCarpintero
07f9e36891 fixes in new log system 2010-04-05 03:02:41 +00:00
AngelCarpintero
f7469950d0 Added a macro MOTION_LOG , no need to add __FUNCTION__ anymore. 2010-04-04 21:50:50 +00:00
AngelCarpintero
79cf297cd4 Implemented http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionLog 2010-04-03 19:34:23 +00:00
AngelCarpintero
3dd5e316e4 Added logfile information to man page 2010-03-30 14:34:54 +00:00
AngelCarpintero
6d35a01104 Make cosmetic changes in comments, description of functions and fix some code to be compliant with CODE STANDARD 2010-03-29 19:24:57 +00:00