From: Andre Noll <maan@systemlinux.org>
Date: Thu, 15 Mar 2007 18:42:39 +0000 (+0100)
Subject: mysql_selector.c: refresh selector info on com_us and com_snp
X-Git-Tag: v0.2.16~7^2~8
X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=35ff75cd0b259077fea9439ecc82dc72d1c2c7c2;p=paraslash.git

mysql_selector.c: refresh selector info on com_us and com_snp
---

diff --git a/mysql_selector.c b/mysql_selector.c
index d7d4ee10..b2a925e0 100644
--- a/mysql_selector.c
+++ b/mysql_selector.c
@@ -900,7 +900,6 @@ write:
 	return info;
 }
 
-
 /* might return NULL */
 static char *get_current_audio_file(void)
 {
@@ -911,6 +910,29 @@ static char *get_current_audio_file(void)
 	return name;
 }
 
+/* If called as child, mmd_lock must be held */
+static void update_mmd(char *info)
+{
+	PARA_DEBUG_LOG("%s", "updating shared memory area\n");
+	strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
+	mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
+}
+
+static void refresh_selector_info(void)
+{
+	char *name = get_current_audio_file();
+	char *info;
+
+	if (!name)
+		return;
+	info = get_selector_info(name);
+	free(name);
+	mmd_lock();
+	update_mmd(info);
+	mmd_unlock();
+	free(info);
+}
+
 /* list attributes / print database info */
 static int com_la_info(int fd, int argc, char *argv[])
 {
@@ -1186,7 +1208,10 @@ int com_picass(int fd, int argc, char *argv[])
  */
 int com_snp(int fd, int argc, char *argv[])
 {
-	return com_set(fd, argc, argv);
+	int ret = com_set(fd, argc, argv);
+	if (ret >= 0)
+		refresh_selector_info();
+	return ret;
 }
 
 /*
@@ -1463,14 +1488,6 @@ out:
 	return ret;
 }
 
-/* If called as child, mmd_lock must be held */
-static void update_mmd(char *info)
-{
-	PARA_DEBUG_LOG("%s", "updating shared memory area\n");
-	strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
-	mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
-}
-
 static void update_audio_file_server_handler(char *name)
 {
 	char *info;
@@ -1492,24 +1509,11 @@ int com_us(__a_unused int fd, int argc, char *argv[])
 		return -E_ESCAPE;
 	ret = update_audio_file(argv[1]);
 	free(tmp);
+	if (ret >= 0)
+		refresh_selector_info();
 	return ret;
 }
 
-static void refresh_selector_info(void)
-{
-	char *name = get_current_audio_file();
-	char *info;
-
-	if (!name)
-		return;
-	info = get_selector_info(name);
-	free(name);
-	mmd_lock();
-	update_mmd(info);
-	mmd_unlock();
-	free(info);
-}
-
 /* select previous / next stream */
 static int com_ps_ns(__a_unused int fd, int argc, char *argv[])
 {