Patch from Derek LaHousse <dlahouss@mtu.edu>
Fixes #648495


--- a/src/logger/gpscomm.c
+++ b/src/logger/gpscomm.c
@@ -23,16 +23,21 @@ along with obdgpslogger.  If not, see <h
 
 #ifdef HAVE_GPSD
 
+#include <stdlib.h>
 #include <gps.h>
 
 struct gps_data_t *opengps(char *server, char *port) {
+#ifdef HAVE_GPSD_V3
+	int ret = 0;
+	struct gps_data_t *g = malloc(sizeof(struct gps_data_t));
+	if (ret = gps_open(server, port, g) == -1)
+		return NULL;
+	gps_stream(g, WATCH_ENABLE|WATCH_NEWSTYLE, NULL);
+#else
 	struct gps_data_t *g = gps_open(server,port);
 	if(NULL == g)
 		return NULL;
 
-#ifdef HAVE_GPSD_V3
-	gps_stream(g, WATCH_ENABLE|WATCH_NEWSTYLE, NULL);
-#else
 	gps_query(g, "o");
 #endif //HAVE_GPSD_V3
 
@@ -40,6 +45,11 @@ struct gps_data_t *opengps(char *server,
 }
 
 void closegps(struct gps_data_t *g) {
+#ifdef HAVE_GPSD_V3
+	gps_stream(g, WATCH_DISABLE, NULL);
+	free(g);
+	g = NULL;
+#endif //HAVE_GPSD_V3
 	gps_close(g);
 }
 
@@ -58,7 +68,7 @@ int getgpsposition(struct gps_data_t *g,
 		count = select(g->gps_fd + 1, &fds, NULL, NULL, &timeout);
 		if(count > 0) {
 #ifdef HAVE_GPSD_V3
-			gps_poll(g);
+			gps_read(g);
 #else
 			gps_query(g, "o");
 #endif //HAVE_GPSD_V3
