The ViaVoice driver should now use the languages table (rather than the language map). (dm)

--- Drivers/Speech/ViaVoice/speech.c
+++ Drivers/Speech/ViaVoice/speech.c
@@ -63,6 +63,8 @@
 static char *sayBuffer = NULL;
 static size_t saySize;

+typedef int MapFunction (int index);
+
 static const char *sampleRates[] = {"8000", "11025", "22050", NULL};
 static const char *abbreviationModes[] = {"on", "off", NULL};
 static const char *numberModes[] = {"word", "year", NULL};
@@ -340,47 +342,6 @@
    },

    {  .identifier = NODEFINEDCODESET  }
-};
-
-static const int languageMap[] = {
-   eciGeneralAmericanEnglish,
-   eciBritishEnglish,
-   eciCastilianSpanish,
-   eciMexicanSpanish,
-   eciStandardFrench,
-   eciCanadianFrench,
-   eciStandardGerman,
-   eciStandardItalian,
-   eciMandarinChinese,
-   eciMandarinChineseGB,
-   eciMandarinChinesePinYin,
-   eciMandarinChineseUCS,
-   eciTaiwaneseMandarin,
-   eciTaiwaneseMandarinBig5,
-   eciTaiwaneseMandarinZhuYin,
-   eciTaiwaneseMandarinPinYin,
-   eciTaiwaneseMandarinUCS,
-   eciBrazilianPortuguese,
-   eciStandardJapanese,
-   eciStandardJapaneseSJIS,
-   eciStandardJapaneseUCS,
-   eciStandardFinnish,
-   eciStandardKorean,
-   eciStandardKoreanUHC,
-   eciStandardKoreanUCS,
-   eciStandardCantonese,
-   eciStandardCantoneseGB,
-   eciStandardCantoneseUCS,
-   eciHongKongCantonese,
-   eciHongKongCantoneseBig5,
-   eciHongKongCantoneseUCS,
-   eciStandardDutch,
-   eciStandardNorwegian,
-   eciStandardSwedish,
-   eciStandardDanish,
-   eciStandardThai,
-   eciStandardThaiTIS,
-   NODEFINEDCODESET
 };

 static const char *const languageNames[] = {
@@ -425,6 +386,11 @@
    NULL
 };

+static int
+mapLanguage (int index) {
+   return languages[index].identifier;
+}
+
 static void
 reportError (ECIHand eci, const char *routine) {
    int status = eciProgStatus(eci);
@@ -434,7 +400,7 @@
 }

 static void
-reportParameter (const char *description, int setting, const char *const *choices, const int *map) {
+reportParameter (const char *description, int setting, const char *const *choices, MapFunction *map) {
    char buffer[0X10];
    const char *value = buffer;

@@ -444,7 +410,7 @@
       int choice = 0;

       while (choices[choice]) {
-	 if (setting == (map? map[choice]: choice)) {
+	 if (setting == (map? map(choice): choice)) {
 	    value = choices[choice];
 	    break;
 	 }
@@ -458,7 +424,7 @@
 }

 static void
-reportGeneralParameter (ECIHand eci, const char *description, enum ECIParam parameter, int setting, const char *const *choices, const int *map) {
+reportGeneralParameter (ECIHand eci, const char *description, enum ECIParam parameter, int setting, const char *const *choices, MapFunction *map) {
    if (parameter != eciNumParams) setting = eciGetParam(eci, parameter);
    reportParameter(description, setting, choices, map);
 }
@@ -477,7 +443,7 @@
 }

 static int
-choiceGeneralParameter (ECIHand eci, const char *description, const char *value, enum ECIParam parameter, const char *const *choices, const int *map) {
+choiceGeneralParameter (ECIHand eci, const char *description, const char *value, enum ECIParam parameter, const char *const *choices, MapFunction *map) {
    int ok = 0;
    int assume = 1;

@@ -485,7 +451,7 @@
       unsigned int setting;

       if (validateChoice(&setting, value, choices)) {
-	 if (map) setting = map[setting];
+	 if (map) setting = map(setting);

          if (setGeneralParameter(eci, description, parameter, setting)) {
 	    ok = 1;
@@ -546,7 +512,7 @@
 }

 static void
-reportVoiceParameter (ECIHand eci, const char *description, enum ECIVoiceParam parameter, const char *const *choices, const int *map) {
+reportVoiceParameter (ECIHand eci, const char *description, enum ECIVoiceParam parameter, const char *const *choices, MapFunction *map) {
    reportParameter(description, getVoiceParameter(eci, parameter), choices, map);
 }

@@ -558,14 +524,14 @@
 }

 static int
-choiceVoiceParameter (ECIHand eci, const char *description, const char *value, enum ECIVoiceParam parameter, const char *const *choices, const int *map) {
+choiceVoiceParameter (ECIHand eci, const char *description, const char *value, enum ECIVoiceParam parameter, const char *const *choices, MapFunction *map) {
    int ok = 0;

    if (*value) {
       unsigned int setting;

       if (validateChoice(&setting, value, choices)) {
-	 if (map) setting = map[setting];
+	 if (map) setting = map(setting);
          if (setVoiceParameter(eci, description, parameter, setting)) ok = 1;
       } else {
         logMessage(LOG_WARNING, "invalid %s setting: %s", description, value);
@@ -835,7 +801,7 @@
    choiceGeneralParameter(eci, "number mode", parameters[PARM_NumberMode], eciNumberMode, numberModes, NULL);
    choiceGeneralParameter(eci, "synth mode", parameters[PARM_SynthMode], eciSynthMode, synthModes, NULL);
    choiceGeneralParameter(eci, "text mode", parameters[PARM_TextMode], eciTextMode, textModes, NULL);
-   choiceGeneralParameter(eci, "language", parameters[PARM_Language], eciLanguageDialect, languageNames, languageMap);
+   choiceGeneralParameter(eci, "language", parameters[PARM_Language], eciLanguageDialect, languageNames, mapLanguage);
    choiceGeneralParameter(eci, "voice", parameters[PARM_Voice], eciNumParams, voices, NULL);

    choiceVoiceParameter(eci, "gender", parameters[PARM_Gender], eciGender, genders, NULL);


Allow Client#loop to take an optional timeout

This allows us to non-blockingly poll for available changes, and to avoid
blocking (eg) a reactor if we've been mistakenly woken up.

--- bindings/ruby/client.c
+++ bindings/ruby/client.c
@@ -1459,20 +1459,28 @@
 }

 static VALUE
-hyperdex_ruby_client_loop(VALUE self)
+hyperdex_ruby_client_loop(int argc, VALUE *argv, VALUE self)
 {
     struct hyperdex_client* client;
     enum hyperdex_client_returncode rc;
     int64_t ret;
     VALUE ops;
     VALUE op;
+    VALUE timeout;
+
+    rb_scan_args(argc, argv, "01", &timeout);
+    if (NIL_P(timeout)) {
+        timeout = INT2NUM(-1);
+    }

     Data_Get_Struct(self, struct hyperdex_client, client);
-    ret = hyperdex_client_loop(client, -1, &rc);
+    ret = hyperdex_client_loop(client, NUM2INT(timeout), &rc);

     if (ret < 0)
     {
-        hyperdex_ruby_client_throw_exception(rc, hyperdex_client_error_message(client));
+        if (rc != HYPERDEX_CLIENT_TIMEOUT) {
+            hyperdex_ruby_client_throw_exception(rc, hyperdex_client_error_message(client));
+        }
         return Qnil;
     }
     else
@@ -1700,7 +1708,8 @@
     class_client = rb_define_class_under(mod_hyperdex_client, "Client", rb_cObject);
     rb_define_alloc_func(class_client, hyperdex_ruby_client_alloc);
     rb_define_method(class_client, "initialize", hyperdex_ruby_client_init, 2);
-    rb_define_method(class_client, "loop", hyperdex_ruby_client_loop, 0);
+    rb_define_method(class_client, "loop", hyperdex_ruby_client_loop, -1);
+
     /* include the generated rb_define_* calls */
 #include "bindings/ruby/prototypes.c"


don't unlock in case of an error

don't unlock in case of an error

--- share/batchrpc.c
+++ share/batchrpc.c
@@ -668,7 +668,6 @@
 		}
 		freelock(&bq->bq_lock);
 	}
-
 	LIST_CACHE_ULOCK(res_batches);

 	/* not found; create */
@@ -676,7 +675,7 @@
 	OPSTAT_INCR("batch-new");
 	rc = SL_RSX_NEWREQ(csvc, SRMT_BATCH_RQ, rq, mq, mp);
 	if (rc)
-		PFL_GOTOERR(out, rc);
+		return (rc);

 	mq->opc = opc;
 	mq->bid = psc_atomic64_inc_getnew(&bid);
@@ -736,7 +735,6 @@
 	} else
 		freelock(&bq->bq_lock);

- out:
 	LIST_CACHE_ULOCK(res_batches);
 	return (rc);
 }


shell: add an action for grouped content

--- shell/mex-main.c
+++ shell/mex-main.c
@@ -1972,6 +1972,33 @@
 }

 static void
+mex_open_group_cb (MxAction *action,
+                   MexData  *data)
+{
+  MexContent *content;
+  MexModel *model;
+
+  content = mex_action_get_content (action);
+
+  model = mex_program_get_feed (MEX_PROGRAM (content));
+
+  if (!model)
+    return;
+
+  g_object_set (content, "last-position-start", FALSE, NULL);
+  mex_content_view_set_context (MEX_CONTENT_VIEW (data->player), model);
+
+  content = mex_model_get_content (model, 1);
+  mex_content_view_set_content (MEX_CONTENT_VIEW (data->player), content);
+
+  /* hide other actors */
+  mex_hide_actor (data, data->slide_show);
+
+  /* show the video player */
+  run_play_transition (data, content, data->player, TRUE);
+}
+
+static void
 cleanup_before_exit (void)
 {
 #if HAVE_REBINDER
@@ -2012,6 +2039,7 @@
 static const gchar *folder_action_mimetypes[] = { "x-grl/box", NULL };
 static const gchar *show_action_mimetypes[] = { "image/", NULL };
 static const gchar *back_action_mimetypes[] = { "x-mex/back", NULL };
+static const gchar *group_action_mimetypes[] = { "x-mex/group", NULL };

 int
@@ -2041,6 +2069,7 @@
   MexActionInfo open_folder = { 0, };
   MexActionInfo show = { 0, };
   MexActionInfo back = { 0, };
+  MexActionInfo group = { 0, };

   /* FIXME: Replace this with a configuration file */
   MexModelCategoryInfo videos = { "videos", _("Videos"), "icon-panelheader-videos", 20, _("Connect an external drive or update your network settings to see Videos here.") };
@@ -2443,6 +2472,13 @@
   back.mime_types = (gchar **)back_action_mimetypes;
   back.priority = G_MAXINT;

+  group.action =
+    mx_action_new_full ("play-group", _("Play"),
+                        G_CALLBACK (mex_open_group_cb), &data);
+  mx_action_set_icon (group.action, "media-watch-mex");
+  group.mime_types = (gchar **)group_action_mimetypes;
+  group.priority = G_MAXINT;
+
   amanager = mex_action_manager_get_default ();
   mex_action_manager_add_action (amanager, &play_from_last);
   mex_action_manager_add_action (amanager, &play_from_begin);
@@ -2452,6 +2488,7 @@
   mex_action_manager_add_action (amanager, &back);
   mex_action_manager_add_action (amanager, &listen);
   mex_action_manager_add_action (amanager, &listen_from_begin);
+  mex_action_manager_add_action (amanager, &group);

   /* Add the default categories to the model manager */
   mmanager = mex_model_manager_get_default ();


Allow transmitter ID to optionally be stored in an external include file

--- apps/dexdrip/dexdrip.c
+++ apps/dexdrip/dexdrip.c
@@ -41,7 +41,7 @@
 //                                   1 = TRUE       0 = FALSE                                       //
 //                                                                                //
 #ifndef CUSTOM_TRANSMITTER_ID
-#warning "Using built-in trasmitter id from dexdrip.c"
+#warning "Using built-in transmitter id from dexdrip.c"

   static XDATA const char transmitter_id[] = "ABCDE";                                               //


pxa270 is xscale

pxa270 is xscale

--- arch/arm/arm/cpufunc.c
+++ arch/arm/arm/cpufunc.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: cpufunc.c,v 1.2 2004/05/19 03:17:06 drahn Exp $	*/
+/*	$OpenBSD: cpufunc.c,v 1.3 2004/12/30 23:43:15 drahn Exp $	*/
 /*	$NetBSD: cpufunc.c,v 1.65 2003/11/05 12:53:15 scw Exp $	*/

 /*
@@ -1120,6 +1120,7 @@
 #ifdef CPU_XSCALE_PXA2X0
 	/* ignore core revision to test PXA2xx CPUs */
 	if ((cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA250 ||
+	    (cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA27X ||
 	    (cputype & ~CPU_ID_XSCALE_COREREV_MASK) == CPU_ID_PXA210) {

 		cpufuncs = xscale_cpufuncs;


PCI: Remove __devinit from pcibios_get_irq_routing_table

pcibios_get_irq_routing_table is an exported symbol.  This results in a
modpost warning:

WARNING: vmlinux.o(.text+0xdca51): Section mismatch: reference to .init.text:pcibios_fixup_bus (between 'pci_scan_child_bus' and 'pci_scan_bus_parented')

Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- arch/i386/pci/pcbios.c
+++ arch/i386/pci/pcbios.c
@@ -412,7 +412,7 @@
 	u16 segment;
 } __attribute__((packed));

-struct irq_routing_table * __devinit pcibios_get_irq_routing_table(void)
+struct irq_routing_table * pcibios_get_irq_routing_table(void)
 {
 	struct irq_routing_options opt;
 	struct irq_routing_table *rt = NULL;


[S390] Rename "idle_time" attribute to "idle_time_us".

Seems that people prefer to have the unit encoded in the attribute
name. Also makes parsing easier.

Now we have:

# cat /sys/devices/system/cpu/cpu0/idle_time_us
131473592

instead of

# cat /sys/devices/system/cpu/cpu0/idle_time
131473592 us

Cc: Arjan van de Ven <9043bf4b08f6c93a2cb55d98c3494b123858348f@infradead.org>
Signed-off-by: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- arch/s390/kernel/smp.c
+++ arch/s390/kernel/smp.c
@@ -788,14 +788,14 @@
 	}
 	new_time = idle->idle_time;
 	spin_unlock_irq(&idle->lock);
-	return sprintf(buf, "%llu us\n", new_time >> 12);
-}
-static SYSDEV_ATTR(idle_time, 0444, show_idle_time, NULL);
+	return sprintf(buf, "%llu\n", new_time >> 12);
+}
+static SYSDEV_ATTR(idle_time_us, 0444, show_idle_time, NULL);

 static struct attribute *cpu_attrs[] = {
 	&attr_capability.attr,
 	&attr_idle_count.attr,
-	&attr_idle_time.attr,
+	&attr_idle_time_us.attr,
 	NULL,
 };


[S390] kvm: fix sleeping function ... at mm/page_alloc.c:2260

commit cc772456ac9b460693492b3a3d89e8c81eda5874
    [S390] fix list corruption in gmap reverse mapping

added a potential dead lock:

BUG: sleeping function called from invalid context at mm/page_alloc.c:2260
in_atomic(): 1, irqs_disabled(): 0, pid: 1108, name: qemu-system-s39
3 locks held by qemu-system-s39/1108:
 #0:  (&kvm->slots_lock){+.+.+.}, at: [<000003e004866542>] kvm_set_memory_region+0x3a/0x6c [kvm]
 #1:  (&mm->mmap_sem){++++++}, at: [<0000000000123790>] gmap_map_segment+0x9c/0x298
 #2:  (&(&mm->page_table_lock)->rlock){+.+.+.}, at: [<00000000001237a8>] gmap_map_segment+0xb4/0x298
CPU: 0 Not tainted 3.1.3 #45
Process qemu-system-s39 (pid: 1108, task: 00000004f8b3cb30, ksp: 00000004fd5978d0)
00000004fd5979a0 00000004fd597920 0000000000000002 0000000000000000
       00000004fd5979c0 00000004fd597938 00000004fd597938 0000000000617e96
       0000000000000000 00000004f8b3cf58 0000000000000000 0000000000000000
       000000000000000d 000000000000000c 00000004fd597988 0000000000000000
       0000000000000000 0000000000100a18 00000004fd597920 00000004fd597960
Call Trace:
([<0000000000100926>] show_trace+0xee/0x144)
 [<0000000000131f3a>] __might_sleep+0x12a/0x158
 [<0000000000217fb4>] __alloc_pages_nodemask+0x224/0xadc
 [<0000000000123086>] gmap_alloc_table+0x46/0x114
 [<000000000012395c>] gmap_map_segment+0x268/0x298
 [<000003e00486b014>] kvm_arch_commit_memory_region+0x44/0x6c [kvm]
 [<000003e004866414>] __kvm_set_memory_region+0x3b0/0x4a4 [kvm]
 [<000003e004866554>] kvm_set_memory_region+0x4c/0x6c [kvm]
 [<000003e004867c7a>] kvm_vm_ioctl+0x14a/0x314 [kvm]
 [<0000000000292100>] do_vfs_ioctl+0x94/0x588
 [<0000000000292688>] SyS_ioctl+0x94/0xac
 [<000000000061e124>] sysc_noemu+0x22/0x28
 [<000003fffcd5e7ca>] 0x3fffcd5e7ca
3 locks held by qemu-system-s39/1108:
 #0:  (&kvm->slots_lock){+.+.+.}, at: [<000003e004866542>] kvm_set_memory_region+0x3a/0x6c [kvm]
 #1:  (&mm->mmap_sem){++++++}, at: [<0000000000123790>] gmap_map_segment+0x9c/0x298
 #2:  (&(&mm->page_table_lock)->rlock){+.+.+.}, at: [<00000000001237a8>] gmap_map_segment+0xb4/0x298

Fix this by freeing the lock on the alloc path. This is ok, since the
gmap table is never freed until we call gmap_free, so the table we are
walking cannot go.

Signed-off-by: Christian Borntraeger <49712f635b03c16d7f4c43df70e49ec8c565813d@de.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- arch/s390/mm/pgtable.c
+++ arch/s390/mm/pgtable.c
@@ -267,7 +267,10 @@
 	struct page *page;
 	unsigned long *new;

+	/* since we dont free the gmap table until gmap_free we can unlock */
+	spin_unlock(&gmap->mm->page_table_lock);
 	page = alloc_pages(GFP_KERNEL, ALLOC_ORDER);
+	spin_lock(&gmap->mm->page_table_lock);
 	if (!page)
 		return -ENOMEM;
 	new = (unsigned long *) page_to_phys(page);


Only invoke setcurcpu() #ifdef MULTIPROCESSOR

--- arch/sgi/sgi/machdep.c
+++ arch/sgi/sgi/machdep.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: machdep.c,v 1.101 2010/04/28 16:20:28 syuu Exp $ */
+/*	$OpenBSD: machdep.c,v 1.102 2010/04/28 21:26:47 miod Exp $ */

 /*
  * Copyright (c) 2003-2004 Opsycon AB  (www.opsycon.se / www.opsycon.com)
@@ -149,10 +149,12 @@
 	extern char exception[], e_exception[];
 	extern char *hw_vendor;

+#ifdef MULTIPROCESSOR
 	/*
 	 * Set curcpu address on primary processor.
 	 */
 	setcurcpu(&cpu_info_primary);
+#endif

 	/*
 	 * Make sure we can access the extended address space.


sse2: fix _mm_stream_si64 GCC < 5.3

sse2: fix _mm_stream_si64 GCC < 5.3

I broke it in 941c09756365122498b897cdebc0e5e209336057.  Oops.

--- simde/x86/sse2.h
+++ simde/x86/sse2.h
@@ -3426,9 +3426,9 @@
 void
 simde_mm_stream_si64 (int64_t* mem_addr, int64_t a) {
 #if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64)
-  #if defined(HEDLEY_GCC_VERSION)
+  #if HEDLEY_GCC_VERSION_CHECK(5,3,0) // https://github.com/gcc-mirror/gcc/commit/821b85a2a0869b5128bd67e192a5a97748cbd90d
     _mm_stream_si64((long long*) mem_addr, a);
-  #elif !defined(HEDLEY_PGI_VERSION)
+  #elif !defined(HEDLEY_PGI_VERSION) && !defined(HEDLEY_GCC_VERSION)
     _mm_stream_si64(mem_addr, a);
   #else
     *mem_addr = a;


sh: Kill off the GENERIC_CALIBRATE_DELAY ifndef.

Now that everyone is using the clock framework directly and we
unconditionally provide our own calibrate_delay() function, having it
wrapped in an ifndef is no longer useful. So, kill it off.

Signed-off-by: Paul Mundt <38b52dbb5f0b63d149982b6c5de788ec93a89032@linux-sh.org>

--- arch/sh/kernel/setup.c
+++ arch/sh/kernel/setup.c
@@ -156,7 +156,7 @@
 			&crash_size, &crash_base);
 	if (ret == 0 && crash_size) {
 		if (crash_base <= 0) {
-			vp = alloc_bootmem_nopanic(crash_size);
+			vp = alloc_bootmem_nopanic(crash_size);
 			if (!vp) {
 				printk(KERN_INFO "crashkernel allocation "
 				       "failed\n");
@@ -185,7 +185,6 @@
 {}
 #endif

-#ifndef CONFIG_GENERIC_CALIBRATE_DELAY
 void __cpuinit calibrate_delay(void)
 {
 	struct clk *clk = clk_get(NULL, "cpu_clk");
@@ -201,7 +200,6 @@
 			 (loops_per_jiffy/(5000/HZ)) % 100,
 			 loops_per_jiffy);
 }
-#endif

 void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
 						unsigned long end_pfn)


Continue processing all other window orders for new remote app windows instead of existing after only looking at part of the information. For instance, window visibility rects are part of the message with the new order and were being ignored.

--- client/X11/xf_rail.c
+++ client/X11/xf_rail.c
@@ -299,6 +299,7 @@
 		appWindow->localWindowOffsetCorrX = 0;
 		appWindow->localWindowOffsetCorrY = 0;

+		/* Ensure window always gets a window title */
 		if (fieldFlags & WINDOW_ORDER_FIELD_TITLE)
 		{
 			char* title = NULL;
@@ -321,8 +322,6 @@
 		HashTable_Add(xfc->railWindows, (void*) (UINT_PTR) orderInfo->windowId, (void*) appWindow);

 		xf_AppWindowInit(xfc, appWindow);
-
-		return TRUE;
 	}
 	else
 	{


svml: require AVX not SSE for {i,u}divrem_epi32

The IIG says that only SSE is required, but due to the types being
__m256i ICC will actually use AVX instructions even if the
implementations don't use AVX.

--- simde/x86/svml.h
+++ simde/x86/svml.h
@@ -3803,7 +3803,7 @@
 SIMDE_FUNCTION_ATTRIBUTES
 simde__m256i
 simde_mm256_idivrem_epi32 (simde__m256i* mem_addr, simde__m256i a, simde__m256i b) {
-  #if defined(SIMDE_X86_SVML_NATIVE) && defined(SIMDE_X86_SSE2_NATIVE)
+  #if defined(SIMDE_X86_SVML_NATIVE) && defined(SIMDE_X86_AVX_NATIVE)
     return _mm256_idivrem_epi32(HEDLEY_REINTERPRET_CAST(__m256i*, mem_addr), a, b);
   #else
     simde__m256i r;
@@ -7147,7 +7147,7 @@
 SIMDE_FUNCTION_ATTRIBUTES
 simde__m256i
 simde_mm256_udivrem_epi32 (simde__m256i* mem_addr, simde__m256i a, simde__m256i b) {
-  #if defined(SIMDE_X86_SVML_NATIVE) && defined(SIMDE_X86_SSE2_NATIVE)
+  #if defined(SIMDE_X86_SVML_NATIVE) && defined(SIMDE_X86_AVX_NATIVE)
     return _mm256_udivrem_epi32(HEDLEY_REINTERPRET_CAST(__m256i*, mem_addr), a, b);
   #else
     simde__m256i r;


Print the LOM type (LOMlite/LOMlite2).

Print the LOM type (LOMlite/LOMlite2).

--- arch/sparc64/dev/lom.c
+++ arch/sparc64/dev/lom.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: lom.c,v 1.14 2009/09/27 17:59:55 kettenis Exp $	*/
+/*	$OpenBSD: lom.c,v 1.15 2009/09/27 18:08:42 kettenis Exp $	*/
 /*
  * Copyright (c) 2009 Mark Kettenis
  *
@@ -336,7 +336,9 @@

 	wdog_register(sc, lom_wdog_cb);

-	printf(": rev %d.%d\n", fw_rev >> 4, fw_rev & 0x0f);
+	printf(": %s rev %d.%d\n",
+	    sc->sc_type < LOM_LOMLITE2 ? "LOMlite" : "LOMlite2",
+	    fw_rev >> 4, fw_rev & 0x0f);
 }

 int


fixed error parsing rdp file: lines without value were ignored before being marked as formatted, resulting in duplicate values being written to the RDP file afterwards.

--- client/common/file.c
+++ client/common/file.c
@@ -49,7 +49,7 @@

 #define INVALID_INTEGER_VALUE		0xFFFFFFFF

-BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, char* name, int value, int index)
+BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value, int index)
 {
 	BOOL bStandard = TRUE;

@@ -229,13 +229,13 @@
 	free(valueA);
 }

-void freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, char* name, char* value, int index)
+void freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, const char* name, const char* value, int index)
 {
 	int ivalue = atoi(value);
 	freerdp_client_rdp_file_set_integer(file, name, ivalue, index);
 }

-BOOL freerdp_client_rdp_file_set_string(rdpFile* file, char* name, char* value, int index)
+BOOL freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value, int index)
 {
 	BOOL bStandard = TRUE;

@@ -436,8 +436,6 @@
 			if ((d2 - d1) != 2)
 				goto next_line; /* improper type length */

-			if (d2 == end)
-				goto next_line; /* no value */

 			*d1 = 0;
 			*d2 = 0;
@@ -514,8 +512,6 @@
 			if ((d2 - d1) != 2)
 				goto next_line; /* improper type length */

-			if (d2 == end)
-				goto next_line; /* no value */

 			*d1 = 0;
 			*d2 = 0;
@@ -1067,7 +1063,7 @@
 		index = freerdp_client_parse_rdp_file_add_line(file, text, -1);
 		line = freerdp_client_rdp_file_find_line_index(file, index);

-		freerdp_client_rdp_file_set_string(file, (char*) name, (char*) value, index);
+		freerdp_client_rdp_file_set_string(file, name, value, index);

 		free(text);
 	}


[PATCH] uml: remove winch sem

[PATCH] uml: remove winch sem

Replace a semaphore (winch_handler_sem) used in atomic code with a
spinlock, and reduces as needed the amount of protected code to the bare
minimum (for instance no kmalloc calls are needed).

This fixes the last problems with spinlocking (in UP mode with DEBUG
options); the semaphore, taken inside spinlocks, caused a "spin_lock was
already locked" warning, without this patch.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <25fbe3e5acbb7edd90bb5fdeec999a792321fbc4@yahoo.it>
Cc: Jeff Dike <f9b6309e85863eba5d28138b6a0f35841ce976d0@addtoit.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- arch/um/drivers/line.c
+++ arch/um/drivers/line.c
@@ -663,11 +663,15 @@
 	return driver;
 }

+static spinlock_t winch_handler_lock;
+LIST_HEAD(winch_handlers);
+
 void lines_init(struct line *lines, int nlines)
 {
 	struct line *line;
 	int i;

+	spin_lock_init(&winch_handler_lock);
 	for(i = 0; i < nlines; i++){
 		line = &lines[i];
 		INIT_LIST_HEAD(&line->chan_list);
@@ -724,31 +728,30 @@
 	return IRQ_HANDLED;
 }

-DECLARE_MUTEX(winch_handler_sem);
-LIST_HEAD(winch_handlers);
-
 void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty)
 {
 	struct winch *winch;

-	down(&winch_handler_sem);
 	winch = kmalloc(sizeof(*winch), GFP_KERNEL);
 	if (winch == NULL) {
 		printk("register_winch_irq - kmalloc failed\n");
-		goto out;
-	}
+		return;
+	}
+
 	*winch = ((struct winch) { .list  	= LIST_HEAD_INIT(winch->list),
 				   .fd  	= fd,
 				   .tty_fd 	= tty_fd,
 				   .pid  	= pid,
 				   .tty 	= tty });
+
+	spin_lock(&winch_handler_lock);
 	list_add(&winch->list, &winch_handlers);
+	spin_unlock(&winch_handler_lock);
+
 	if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
 			  SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
 			  "winch", winch) < 0)
 		printk("register_winch_irq - failed to register IRQ\n");
- out:
-	up(&winch_handler_sem);
 }

 static void unregister_winch(struct tty_struct *tty)
@@ -756,7 +759,7 @@
 	struct list_head *ele;
 	struct winch *winch, *found = NULL;

-	down(&winch_handler_sem);
+	spin_lock(&winch_handler_lock);
 	list_for_each(ele, &winch_handlers){
 		winch = list_entry(ele, struct winch, list);
                 if(winch->tty == tty){
@@ -764,20 +767,25 @@
                         break;
                 }
         }
-
         if(found == NULL)
-                goto out;
+		goto err;
+
+	list_del(&winch->list);
+	spin_unlock(&winch_handler_lock);

         if(winch->pid != -1)
                 os_kill_process(winch->pid, 1);

         free_irq(WINCH_IRQ, winch);
-        list_del(&winch->list);
         kfree(winch);
- out:
-	up(&winch_handler_sem);
-}
-
+
+	return;
+err:
+	spin_unlock(&winch_handler_lock);
+}
+
+/* XXX: No lock as it's an exitcall... is this valid? Depending on cleanup
+ * order... are we sure that nothing else is done on the list? */
 static void winch_cleanup(void)
 {
 	struct list_head *ele;
@@ -786,6 +794,9 @@
 	list_for_each(ele, &winch_handlers){
 		winch = list_entry(ele, struct winch, list);
 		if(winch->fd != -1){
+			/* Why is this different from the above free_irq(),
+			 * which deactivates SIGIO? This searches the FD
+			 * somewhere else and removes it from the list... */
 			deactivate_fd(winch->fd, WINCH_IRQ);
 			os_close_file(winch->fd);
 		}


x86: apic - calibrate_APIC_clock remove redundant irq-enable-disable

Impact: cleanup

lapic_timer_setup is self-protected with local_irq_save/restore
no need to use them in caller and levt is the per-cpu variable so
no concurrent access from another cpu.

Signed-off-by: Cyrill Gorcunov <7a1ea01eee6961eb1e372e3508c2670446d086f4@gmail.com>
Acked-by: "Maciej W. Rozycki" <78f3a3d9d6e4d907a7d12e475d0a751d6b7e256b@linux-mips.org>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- arch/x86/kernel/apic.c
+++ arch/x86/kernel/apic.c
@@ -672,12 +672,8 @@
 		while (lapic_cal_loops <= LAPIC_CAL_LOOPS)
 			cpu_relax();

-		local_irq_disable();
-
 		/* Stop the lapic timer */
 		lapic_timer_setup(CLOCK_EVT_MODE_SHUTDOWN, levt);
-
-		local_irq_enable();

 		/* Jiffies delta */
 		deltaj = lapic_cal_j2 - lapic_cal_j1;


KVM: x86 emulator: fix LMSW able to clear cr0.pe

LMSW is documented not to be able to clear cr0.pe; make it so.

Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>

--- arch/x86/kvm/emulate.c
+++ arch/x86/kvm/emulate.c
@@ -3211,7 +3211,7 @@
 			c->dst.val = ops->get_cr(0, ctxt->vcpu);
 			break;
 		case 6: /* lmsw */
-			ops->set_cr(0, (ops->get_cr(0, ctxt->vcpu) & ~0x0ful) |
+			ops->set_cr(0, (ops->get_cr(0, ctxt->vcpu) & ~0x0eul) |
 				    (c->src.val & 0x0f), ctxt->vcpu);
 			c->dst.type = OP_NONE;
 			break;


KVM: x86 emulator: Fix emulate_grp3 return values

This patch lets emulate_grp3() return X86EMUL_* return codes instead
of hardcoded ones.

Signed-off-by: Mohammed Gamal <0584eb32754a96e8f6efc08926f53e7b9e269472@gmail.com>
Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>

--- arch/x86/kvm/emulate.c
+++ arch/x86/kvm/emulate.c
@@ -1424,9 +1424,9 @@
 		emulate_1op_rax_rdx("idiv", c->src, *rax, *rdx, ctxt->eflags);
 		break;
 	default:
-		return 0;
-	}
-	return 1;
+		return X86EMUL_UNHANDLEABLE;
+	}
+	return X86EMUL_CONTINUE;
 }

 static inline int emulate_grp45(struct x86_emulate_ctxt *ctxt,
@@ -3172,7 +3172,7 @@
 		ctxt->eflags ^= EFLG_CF;
 		break;
 	case 0xf6 ... 0xf7:	/* Grp3 */
-		if (!emulate_grp3(ctxt, ops))
+		if (emulate_grp3(ctxt, ops) != X86EMUL_CONTINUE)
 			goto cannot_emulate;
 		break;
 	case 0xf8: /* clc */


x86: fix NX bit handling in change_page_attr()

This patch fixes a bug of change_page_attr/change_page_attr_addr on
Intel i386/x86_64 CPUs.  After changing page attribute to be
executable with these functions, the page remains un-executable on
Intel i386/x86_64 CPU.  Because on Intel i386/x86_64 CPU, only if the
"NX" bits of all three level page tables are cleared (PAE is enabled),
the corresponding page is executable (refer to section 4.13.2 of Intel
64 and IA-32 Architectures Software Developer's Manual).  So, the bug
is fixed through clearing the "NX" bit of PMD when splitting the huge
PMD.

Signed-off-by: Huang Ying <b1ed892af366400004b51f70e40351e33707b6c4@intel.com>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- arch/x86/mm/pageattr.c
+++ arch/x86/mm/pageattr.c
@@ -130,8 +130,13 @@
 		set_pte(&pbase[i], pfn_pte(addr >> PAGE_SHIFT, ref_prot));

 	/*
-	 * Install the new, split up pagetable:
-	 */
+	 * Install the new, split up pagetable. Important detail here:
+	 *
+	 * On Intel the NX bit of all levels must be cleared to make a
+	 * page executable. See section 4.13.2 of Intel 64 and IA-32
+	 * Architectures Software Developer's Manual).
+	 */
+	ref_prot = pte_pgprot(pte_mkexec(pte_clrhuge(*kpte)));
 	__set_pmd_pte(kpte, address, mk_pte(base, ref_prot));
 	base = NULL;


xen: fix compile issue if XEN is enabled but XEN_PVHVM is disabled

Signed-off-by: Stefano Stabellini <22a0c6385d750d07aa383c9f813cf6f0228657d8@eu.citrix.com>

--- arch/x86/xen/suspend.c
+++ arch/x86/xen/suspend.c
@@ -28,6 +28,7 @@

 void xen_hvm_post_suspend(int suspend_cancelled)
 {
+#ifdef CONFIG_XEN_PVHVM
 	int cpu;
 	xen_hvm_init_shared_info();
 	xen_callback_vector();
@@ -37,6 +38,7 @@
 			xen_setup_runstate_info(cpu);
 		}
 	}
+#endif
 }

 void xen_post_suspend(int suspend_cancelled)


rawmidi: allow timestamp reads only for the appropriate read mode

Signed-off-by: Jaroslav Kysela <72edd5e1a572f82f059ccbb83c92b74d6cb051ff@perex.cz>

--- src/rawmidi/rawmidi.c
+++ src/rawmidi/rawmidi.c
@@ -1112,5 +1112,7 @@
 	assert(rawmidi);
 	assert(rawmidi->stream == SND_RAWMIDI_STREAM_INPUT);
 	assert(buffer || size == 0);
+	if ((rawmidi->params_mode & SNDRV_RAWMIDI_MODE_FRAMING_MASK) == SNDRV_RAWMIDI_MODE_FRAMING_TSTAMP)
+		return -EINVAL;
 	return (rawmidi->ops->tread)(rawmidi, tstamp, buffer, size);
 }


handle empty collections when joining

handle empty collections when joining

--- src/join.h
+++ src/join.h
@@ -14,9 +14,11 @@
 std::string join(std::vector<T>& elems, S& delim) {
     std::stringstream ss;
     typename std::vector<T>::iterator e = elems.begin();
-    ss << *e++;
-    for (; e != elems.end(); ++e) {
-        ss << delim << *e;
+    if (e != elems.end()) {
+        ss << *e++;
+        for (; e != elems.end(); ++e) {
+            ss << delim << *e;
+        }
     }
     return ss.str();
 }
@@ -26,9 +28,11 @@
 std::string join(std::list<T>& elems, S& delim) {
     std::stringstream ss;
     typename std::list<T>::iterator e = elems.begin();
-    ss << *e++;
-    for (; e != elems.end(); ++e) {
-        ss << delim << *e;
+    if (e != elems.end()) {
+        ss << *e++;
+        for (; e != elems.end(); ++e) {
+            ss << delim << *e;
+        }
     }
     return ss.str();
 }


fix memory leak in oidc_jwk_to_json

fix memory leak in oidc_jwk_to_json

--- src/jose.c
+++ src/jose.c
@@ -306,6 +306,7 @@
 		return FALSE;
 	}
 	*s_json = apr_pstrdup(pool, s);
+	free(s);
 	return TRUE;
 }


Added new SMP_SYSTEM_CONTROL values and changelog of new SM protocol version 26

--- simplemotion_defs.h
+++ simplemotion_defs.h
@@ -20,7 +20,7 @@
 /* SMV2 protocol change log:
  * Version 20:
  *   -V20 was introduced with Argon FW 1.0.0 and present at least until 1.4.0
- * Version 21 (is backwards compatible in syntax but not in setpoint behavior, see details below):
+ * Version 25 (is backwards compatible in syntax but not in setpoint behavior, see details below):
  *   -V25 was introduced with IONI
  *   -setpoint calculation is different:
  *     now there is only one common setpoint and all ABS and INC commands (buffered & instant)
@@ -31,6 +31,10 @@
  *    this makes it possible to insert any parameter read/write commands in middle of buffered motion.
  *   -implemented watchdog functionality in new param SMP_FAULT_BEHAVIOR
  *   -added param SMP_ADDRESS_OFFSET
+ * Version 26:
+ *    - fast SM command added (actually is also present in late V25 too, but as unofficial feature)
+ *    - watchdog timout now resets bitrate to default and aborts buffered motion
+ *
  */

 /* Important when using SMV2 protocol:
@@ -344,6 +348,11 @@
 	#define SMP_SYSTEM_CONTROL_MEASURE_MOTOR_RL 256
 	//resets position mode FB and setpoint values to 0, and also resets homing status. useful after using in vel or torq mode.
 	#define SMP_SYSTEM_CONTROL_RESET_FB_AND_SETPOINT 512
+	//writes various FW version specific values into debug parameters
+	#define SMP_SYSTEM_CONTROL_GET_SPECIAL_DATA 1024
+	//write SM bus SM_CRCINIT constant modifier. special purposes only, don't use if unsure because
+	//it is one time programmable variable (irreversible operation, can't be ever reset to default by provided methods)
+	#define SMP_SYSTEM_CONTROL_MODIFY_CRCINIT 262144

 	//follow error tolerance for position control:
 #define SMP_POS_FERROR_TRIP 555


Added a json format.

Added a json format.

--- src/jxtl.c
+++ src/jxtl.c
@@ -44,7 +44,38 @@
       *c = apr_tolower( *c );
     }
   }
-
+  else if ( apr_strnatcasecmp( format_name, "json" ) == 0 ) {
+    for ( c = value; *c; c++ ) {
+      if ( *c > 0x1F ) {
+        if ( *c == '\\' || *c == '/' || *c == '"' ) {
+          APR_ARRAY_PUSH( format_data->string_array, char ) = '\\';
+        }
+        APR_ARRAY_PUSH( format_data->string_array, char ) = *c;
+      }
+      else {
+        APR_ARRAY_PUSH( format_data->string_array, char ) = '\\';
+        switch ( *c ) {
+        case '\b':
+          APR_ARRAY_PUSH( format_data->string_array, char ) = 'b';
+          break;
+        case '\f':
+          APR_ARRAY_PUSH( format_data->string_array, char ) = 'f';
+          break;
+        case '\n':
+          APR_ARRAY_PUSH( format_data->string_array, char ) = 'n';
+          break;
+        case '\r':
+          APR_ARRAY_PUSH( format_data->string_array, char ) = 'r';
+          break;
+        case '\t':
+          APR_ARRAY_PUSH( format_data->string_array, char ) = 't';
+          break;
+        }
+      }
+    }
+    ret_value = apr_pstrdup( format_data->mp,
+                             (char *) format_data->string_array->elts );
+  }
   return ret_value;
 }


Flipping the order of BackgroundModeManager and StatusTray members so that the StatusTray is not deleted before the BackgroundModeManager. Technically this should not be an issue, but it can occur if the NOTIFICATION_APP_TERMINATING notification is not sent.

BUG=101082
TEST=passes existing, but there are no repro steps for the crash to test

Review URL: http://codereview.chromium.org/8393028

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@107644 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/browser/browser_process_impl.h
+++ chrome/browser/browser_process_impl.h
@@ -247,9 +247,9 @@

   scoped_ptr<TabCloseableStateWatcher> tab_closeable_state_watcher_;

+  scoped_ptr<StatusTray> status_tray_;
+
   scoped_ptr<BackgroundModeManager> background_mode_manager_;
-
-  scoped_ptr<StatusTray> status_tray_;

   bool created_safe_browsing_service_;
   scoped_refptr<SafeBrowsingService> safe_browsing_service_;


src/update_handler: add assertions for storepath availability

The calling code must ensure this is set, but we should assert that this
condition is met before continuing and running into null pointer
dereferences.

Signed-off-by: Enrico Jorns <a2e5f936c390f36494e46e71bcfbe365bb1e8c49@pengutronix.de>

--- src/update_handler.c
+++ src/update_handler.c
@@ -444,6 +444,10 @@
 	gchar *store = NULL;
 	gchar *tmpdir = NULL;
 	gboolean seed_mounted = FALSE;
+
+	g_assert_nonnull(r_context()->install_info);
+	g_assert_nonnull(r_context()->install_info->mounted_bundle);
+	g_assert_nonnull(r_context()->install_info->mounted_bundle->storepath);

 	if (r_context()->config->use_desync) {
 		/* TODO: do something clever to locate and/or generate the seed index file */


Fix derpus thing

Fix derpus thing

--- src/lcdc.c
+++ src/lcdc.c
@@ -305,7 +305,7 @@

 				if(state->lcdc.lcd_control.win)
 				{
-					//dmg_window_render(state);
+					dmg_window_render(state);
 				}

 				if(state->lcdc.lcd_control.obj)


Update pcCom.c

Update pcCom.c

--- src/user_app/pcCom.c
+++ src/user_app/pcCom.c
@@ -107,7 +107,7 @@
 		printf("8 -> anti emergency\n");
 		printf("9 -> start mission\n");
 		printf("10 -> stop mission\n");
-		printf("-1 to close the programm\n");
+		printf("-1 to close the program\n");

 		pthread_mutex_unlock(&displayMutex);


pki: Make sure we don't double free pointers.

--- src/pki_crypto.c
+++ src/pki_crypto.c
@@ -774,12 +774,16 @@

             ssh_string_burn(p);
             ssh_string_free(p);
+            p = NULL;
             ssh_string_burn(g);
             ssh_string_free(g);
+            g = NULL;
             ssh_string_burn(q);
             ssh_string_free(q);
+            q = NULL;
             ssh_string_burn(n);
             ssh_string_free(n);
+            n = NULL;

             break;
         case SSH_KEYTYPE_RSA:
@@ -803,8 +807,10 @@

             ssh_string_burn(e);
             ssh_string_free(e);
+            e = NULL;
             ssh_string_burn(n);
             ssh_string_free(n);
+            n = NULL;

             break;
         case SSH_KEYTYPE_ECDSA:


virCryptoGenerateRandom: rename ret

virCryptoGenerateRandom: rename ret

This function allocates a buffer, fills it in with random bytes
and then returns it. However, the buffer is held in @buf
variable, therefore having @ret variable which does not hold
return value of the function is misleading.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Eric Blake <a9da18479c871fe903d9590822cfe2629c6a4d11@redhat.com>

--- src/util/vircrypto.c
+++ src/util/vircrypto.c
@@ -329,16 +329,16 @@
 virCryptoGenerateRandom(size_t nbytes)
 {
     uint8_t *buf;
-    int ret;
+    int rv;

     if (VIR_ALLOC_N(buf, nbytes) < 0)
         return NULL;

 #if WITH_GNUTLS
     /* Generate the byte stream using gnutls_rnd() if possible */
-    if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, buf, nbytes)) < 0) {
+    if ((rv = gnutls_rnd(GNUTLS_RND_RANDOM, buf, nbytes)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to generate byte stream, ret=%d"), ret);
+                       _("failed to generate byte stream, rv=%d"), rv);
         VIR_FREE(buf);
         return NULL;
     }
@@ -346,8 +346,8 @@
     /* If we don't have gnutls_rnd(), we will generate a less cryptographically
      * strong master buf from /dev/urandom.
      */
-    if ((ret = virRandomBytes(buf, nbytes)) < 0) {
-        virReportSystemError(-ret, "%s", _("failed to generate byte stream"));
+    if ((rv = virRandomBytes(buf, nbytes)) < 0) {
+        virReportSystemError(-rv, "%s", _("failed to generate byte stream"));
         VIR_FREE(buf);
         return NULL;
     }


Fix virNetDevWaitDadFinish stub

Fix virNetDevWaitDadFinish stub

Build on non-Linux fails because the virNetDevWaitDadFinish() stub
has unused parameters. Fix by adding appropriate ATTRIBUTE_UNUSED
for these parameters.

Pushing under build-breaker rule.

--- src/util/virnetdev.c
+++ src/util/virnetdev.c
@@ -1527,7 +1527,8 @@

 /* return after DAD finishes for all known IPv6 addresses or an error */
 int
-virNetDevWaitDadFinish(virSocketAddrPtr *addrs, size_t count)
+virNetDevWaitDadFinish(virSocketAddrPtr *addrs ATTRIBUTE_UNUSED,
+                       size_t count ATTRIBUTE_UNUSED)
 {
     virReportSystemError(ENOSYS, "%s",
                          _("Unable to wait for IPv6 DAD on this platform"));


Added a timer class called TicToc.

Added a timer class called TicToc.

error: pathspec 'src/utility/tictoc.h' did not match any file(s) known to git

--- src/utility/tictoc.h
+++ src/utility/tictoc.h
@@ -0,0 +1,51 @@
+/*
+ * TicToc.h
+ *
+ *  Created on: Nov 29, 2016
+ *      Author: isovic
+ */
+
+#ifndef SRC_CONSENSUS_TicToc_H_
+#define SRC_CONSENSUS_TicToc_H_
+
+#include <time.h>
+
+class TicToc {
+ public:
+  TicToc();
+  ~TicToc();
+
+  void start();
+  void stop();
+  double get_secs();
+  double get_msecs();
+
+ private:
+  struct timespec start_, stop_;
+};
+
+TicToc::TicToc() {
+}
+
+TicToc::~TicToc() {
+}
+
+void TicToc::start() {
+  clock_gettime(CLOCK_MONOTONIC_RAW, &start_);
+}
+
+void TicToc::stop() {
+  clock_gettime(CLOCK_MONOTONIC_RAW, &stop_);
+}
+
+double TicToc::get_secs() {
+  double delta_us = (stop_.tv_sec - start_.tv_sec) * 1000000.0 + (stop_.tv_nsec - start_.tv_nsec) / 1000.0;
+  return delta_us / 1000000.0;
+}
+
+double TicToc::get_msecs() {
+  double delta_us = (stop_.tv_sec - start_.tv_sec) * 1000000.0 + (stop_.tv_nsec - start_.tv_nsec) / 1000.0;
+  return delta_us / 1000.0;
+}
+
+#endif /* SRC_CONSENSUS_TicToc_H_ */


VCL: add event registration to listen session in select()

Change-Id: Ie2e8f4ec3a7ec1018e5f9ca6f28f8cb18beaa814
Signed-off-by: Dave Wallace <0ed937c0e4b2f09f7bc24acf16cee52b8a199d5f@gmail.com>

--- src/vcl/vppcom.c
+++ src/vcl/vppcom.c
@@ -460,7 +460,7 @@
 }

 /**
- * @brief vce_epoll_wait_connect_request_handler_fn
+ * @brief vce_poll_wait_connect_request_handler_fn
  * - used by vppcom_epoll_xxxx() for listener sessions
  * - when a vl_api_accept_session_t_handler() generates an event
  *   this callback is alerted and sets the fields that vppcom_epoll_wait()
@@ -469,7 +469,7 @@
  * @param arg - void* to be cast to vce_event_handler_reg_t*
  */
 void
-vce_epoll_wait_connect_request_handler_fn (void *arg)
+vce_poll_wait_connect_request_handler_fn (void *arg)
 {
   vce_event_handler_reg_t *reg = (vce_event_handler_reg_t *) arg;
   vce_event_t *ev;
@@ -3462,8 +3462,30 @@
                       bits_set = VPPCOM_EBADFD;
                       goto select_done;
                     }
-
-                  rv = vppcom_session_read_ready (session, session_index);
+                  if (session->state & STATE_LISTEN)
+                    {
+                      vce_event_handler_reg_t *reg = 0;
+                      vce_event_key_t evk;
+
+                      /* Check if handler already registered for this
+                       * event.
+                       * If not, register handler for connect_request event
+                       * on listen_session_index
+                       */
+                      evk.session_index = session_index;
+                      evk.eid = VCL_EVENT_CONNECT_REQ_ACCEPTED;
+                      reg = vce_get_event_handler (&vcm->event_thread, &evk);
+                      if (!reg)
+                        reg = vce_register_handler (&vcm->event_thread, &evk,
+                                    vce_poll_wait_connect_request_handler_fn);
+                      rv = vppcom_session_read_ready (session, session_index);
+                      if (rv > 0)
+                        {
+                          vce_unregister_handler (&vcm->event_thread, reg);
+                        }
+                    }
+                  else
+                    rv = vppcom_session_read_ready (session, session_index);
                   clib_spinlock_unlock (&vcm->sessions_lockp);
                   if (except_map && vcm->ex_bitmap &&
                       clib_bitmap_get (vcm->ex_bitmap, session_index) &&
@@ -3774,7 +3796,7 @@
 	  evk.eid = VCL_EVENT_CONNECT_REQ_ACCEPTED;
 	  vep_session->poll_reg =
 	    vce_register_handler (&vcm->event_thread, &evk,
-				  vce_epoll_wait_connect_request_handler_fn);
+				  vce_poll_wait_connect_request_handler_fn);
 	}
       if (VPPCOM_DEBUG > 1)
 	clib_warning ("VCL<%d>: EPOLL_CTL_ADD: vep_idx %u, "


Added a few new exif tag identifiers.

Added a few new exif tag identifiers.

--- src/vw/Camera/Exif.h
+++ src/vw/Camera/Exif.h
@@ -84,7 +84,7 @@
   static const uint16 EXIF_RelatedImageWidth           = 0x1001;
   static const uint16 EXIF_RelatedImageLength          = 0x1002;
   static const uint16 EXIF_CFARepeatPatternDim         = 0x828D;
-  //  static const uint16 EXIF_CFAPattern                 =  0x828E;
+  static const uint16 EXIF_CFAPattern1                 = 0x828E;
   static const uint16 EXIF_BatteryLevel                = 0x828F;
   static const uint16 EXIF_Copyright                   = 0x8298;
   static const uint16 EXIF_ExposureTime                = 0x829A;
@@ -112,11 +112,17 @@
   static const uint16 EXIF_LightSource                 = 0x9208;
   static const uint16 EXIF_Flash                       = 0x9209;
   static const uint16 EXIF_FocalLength                 = 0x920A;
+  static const uint16 EXIF_SubjectArea                 = 0x9214;
   static const uint16 EXIF_MakerNote                   = 0x927C;
   static const uint16 EXIF_UserComment                 = 0x9286;
   static const uint16 EXIF_SubSecTime                  = 0x9290;
   static const uint16 EXIF_SubSecTimeOriginal          = 0x9291;
   static const uint16 EXIF_SubSecTimeDigitized         = 0x9292;
+  static const uint16 EXIF_WinXPTitle                  = 0x9C9B; // windows-only - not part of exif standard.
+  static const uint16 EXIF_WinXPComment                = 0x9C9C; // windows-only - not part of exif standard.
+  static const uint16 EXIF_WinXPAuthor                 = 0x9C9D; // windows-only - not part of exif standard.
+  static const uint16 EXIF_WinXPKeywords               = 0x9C9E; // windows-only - not part of exif standard.
+  static const uint16 EXIF_WinXPSubject                = 0x9C9F; // windows-only - not part of exif standard.
   static const uint16 EXIF_FlashPixVersion             = 0xA000;
   static const uint16 EXIF_ColorSpace                  = 0xA001;
   static const uint16 EXIF_PixelXDimension             = 0xA002;
@@ -143,8 +149,9 @@
   static const uint16 EXIF_GainControl                 = 0xA407;
   static const uint16 EXIF_Contrast                    = 0xA408;
   static const uint16 EXIF_Saturation                  = 0xA409;
-  static const uint16 EXIF_Sharpness                   = 0xA40a;
-  static const uint16 EXIF_SubjectDistanceRange        = 0xA40c;
+  static const uint16 EXIF_Sharpness                   = 0xA40A;
+  static const uint16 EXIF_SubjectDistanceRange        = 0xA40C;
+  static const uint16 EXIF_ImageUniqueId               = 0xA420;

   // Module Specific Exceptions
   VW_DEFINE_EXCEPTION(ExifErr, vw::Exception);


client: Fix handling display->reader_count if poll fails

In wl_display_dispatch_queue, if poll fails then it would previously
return immediately and leak a reference in display->reader_count. Then
if the application ignores the error and tries to read again it will
block forever. This can happen for example if the poll fails with
EINTR which the application might consider to be a recoverable error.
This patch makes it cancel the read so the reader_count will be
decremented when poll fails.

--- src/wayland-client.c
+++ src/wayland-client.c
@@ -1210,8 +1210,10 @@

 	pfd[0].fd = display->fd;
 	pfd[0].events = POLLIN;
-	if (poll(pfd, 1, -1) == -1)
+	if (poll(pfd, 1, -1) == -1) {
+		wl_display_cancel_read(display);
 		return -1;
+	}

 	pthread_mutex_lock(&display->mutex);


Fixing small bug in empty problems

Fixing small bug in empty problems

--- reference/impl/buildReference.c
+++ reference/impl/buildReference.c
@@ -72,7 +72,9 @@
         group_destructEndIterator(parentEndIt);
     }
     assert(flower_getAttachedStubEndNumber(flower) % 2 == 0);
-    assert(flower_getAttachedStubEndNumber(flower) > 0);
+    if(flower_getBlockEndNumber(flower) > 0) {
+        assert(flower_getAttachedStubEndNumber(flower) > 0);
+    }
     return newEnds;
 }


Don't complain if 0 bytes are written to the tun device, simply do nothing.


Use defined(IP_RECVDSTADDR) instead of defined(__FreeBSD__).

--- src/rtpp_network_io.c
+++ src/rtpp_network_io.c
@@ -46,7 +46,7 @@
         struct cmsghdr hdr;
         unsigned char buf[CMSG_SPACE(1024)];
     } cmsgbuf;
-#if !defined(__FreeBSD__)
+#if !defined(IP_RECVDSTADDR)
     struct in_pktinfo *pktinfo;
 #endif
     struct cmsghdr *cmsg;
@@ -71,7 +71,7 @@
     *tolen = 0;
     for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
       cmsg = CMSG_NXTHDR(&msg, cmsg)) {
-#if defined(__FreeBSD__)
+#if defined(IP_RECVDSTADDR)
         if (cmsg->cmsg_level == IPPROTO_IP &&
           cmsg->cmsg_type == IP_RECVDSTADDR) {
             memcpy(&satosin(to)->sin_addr, CMSG_DATA(cmsg),


fix possible read of freed memory

fix possible read of freed memory

--- src/rtpsession_inet.c
+++ src/rtpsession_inet.c
@@ -1003,8 +1003,8 @@
 				mp=rtp_session_network_simulate(session,mp);
 			/* then parse the message and put on jitter buffer queue */
 			if (mp){
-				rtp_session_rtp_parse(session, mp, user_ts, (struct sockaddr*)&remaddr,addrlen);
 				update_recv_bytes(session,mp->b_wptr-mp->b_rptr);
+				rtp_session_rtp_parse(session, mp, user_ts, (struct sockaddr*)&remaddr,addrlen);
 			}
 			session->rtp.cached_mp=NULL;
 			/*for bandwidth measurements:*/
@@ -1024,8 +1024,8 @@
 					mp=rtp_session_network_simulate(session,NULL);
 					if (mp){
 						/* then parse the message and put on jitter buffer queue */
-						rtp_session_rtp_parse(session, mp, user_ts, (struct sockaddr*)&session->rtp.rem_addr,session->rtp.rem_addrlen);
 						update_recv_bytes(session,msgdsize(mp));
+						rtp_session_rtp_parse(session, mp, user_ts, (struct sockaddr*)&session->rtp.rem_addr,session->rtp.rem_addrlen);
 					}
 				}
 			}


Fixing memory leak in syntax definitions

--- src/runtime/runtime.c
+++ src/runtime/runtime.c
@@ -110,10 +110,11 @@
 		case TYPE_SYNTAX_RULES:
 			move = calloc( 1, sizeof( token_t ));
 			move->type = TYPE_SYNTAX;
-			move->down = frame->ptr;
-
+			move->down = clone_tokens( frame->ptr );
+
+			gc_unmark( move );
 			frame_add_token_noclone( frame, ext_proc_token( builtin_return_first ));
-			frame_add_token( frame, move );
+			frame_add_token_noclone( frame, move );

 			frame->ptr = NULL;
 			break;


Fix possible race in platform test.

Fix possible race in platform test.


FIXED: apparently using yajl_gen_print_function instead of internal generator buffer is the only option, because if generator is freed using g_free internal buffer slowly leaks memory

--- src/serializer/json.c
+++ src/serializer/json.c
@@ -421,12 +421,19 @@
 {
 	yajl_gen gen = yajl_gen_alloc(NULL);
 	yajl_gen_status status;
+	GString *out_buffer;
+
+	out_buffer = g_string_new(NULL);
+	yajl_gen_config(gen, yajl_gen_print_callback,
+	    (yajl_print_t)g_string_append_len,(void *) out_buffer);

 	if ((status = rpc_json_write_object(gen, obj)) != yajl_gen_status_ok)
 		goto end;

-	status = yajl_gen_get_buf(gen, (const uint8_t **)frame, size);
-end:	g_free(gen);
+	*size = out_buffer->len;
+
+end:	yajl_gen_free(gen);
+	*frame = g_string_free(out_buffer, false);
 	return (status);
 }


boost the number of rmc threads

boost the number of rmc threads

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@12167 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- slashd/rpc_mds.h
+++ slashd/rpc_mds.h
@@ -40,7 +40,7 @@
 #define SLM_RMI_REPSZ			1320
 #define SLM_RMI_SVCNAME			"slmrmi"

-#define SLM_RMC_NTHREADS		8
+#define SLM_RMC_NTHREADS		16
 #define SLM_RMC_NBUFS			1024
 #define SLM_RMC_BUFSZ			512
 #define SLM_RMC_REPSZ			588


- BIG replacement XIV: added int8_t ifdef SUNOS

--- src/lib/common.h
+++ src/lib/common.h
@@ -38,6 +38,7 @@
 //@{

 #ifdef SUNOS
+typedef char uint8_t;
 typedef short int int16_t;
 typedef int int32_t;
 typedef long int64_t;


missing a case

missing a case

--- training/chapter6/004broad_cover.c
+++ training/chapter6/004broad_cover.c
@@ -34,7 +34,7 @@

 	colors[first_white_row][first_white_col] = 1;

-	//第一个点，向右，第二个点只能向下
+	//第一个点，向右，第二个点在右下
 	if(first_white_col + 1 < cols && colors[first_white_row][first_white_col + 1] == 0
 		&& first_white_row + 1 < rows &&  colors[first_white_row+1][first_white_col + 1] == 0 ){
 		colors[first_white_row][first_white_col+1] = 1;
@@ -50,11 +50,11 @@
 	//第一个点，向下
 	if(first_white_row + 1 < rows && colors[first_white_row+1][first_white_col] == 0){
 		colors[first_white_row+1][first_white_col] = 1;
-		if(first_white_col - 1 >= 0 && colors[first_white_row-1][first_white_col+1] == 0){
-			//第二个点向左
-			colors[first_white_row-1][first_white_col+1] = 1;
+		if(first_white_col - 1 >= 0 && colors[first_white_row+1][first_white_col-1] == 0){
+			//第二个点在左下
+			colors[first_white_row+1][first_white_col-1] = 1;
 			result += cover(colors, rows, cols);
-			colors[first_white_row-1][first_white_col+1] = 0;
+			colors[first_white_row+1][first_white_col-1] = 0;
 		}
 		if(first_white_col + 1 < cols && colors[first_white_row+1][first_white_col+1] == 0){
 			//第二个点向右
@@ -64,6 +64,18 @@
 		}

 		colors[first_white_row+1][first_white_col] = 0;
+	}
+
+	//第一个点，向右，第二个点，向下
+	if(first_white_row + 1 < rows && colors[first_white_row+1][first_white_col] == 0
+		&& first_white_col + 1 < cols && colors[first_white_row][first_white_col+1] == 0){
+		colors[first_white_row+1][first_white_col] = 1;
+		colors[first_white_row][first_white_col+1] = 1;
+
+		result += cover(colors, rows, cols);
+
+		colors[first_white_row+1][first_white_col] = 0;
+		colors[first_white_row][first_white_col+1] = 0;
 	}

 	colors[first_white_row][first_white_col] = 0;


liblink: don't search for an import file with an absolute path

This restores the old behaviour, and makes it possible to
continue to use 6g and 6l directly, rather than the go tool,
with dot imports.

R=rsc
CC=golang-dev
https://codereview.appspot.com/43710043

--- src/liblink/ld.c
+++ src/liblink/ld.c
@@ -61,11 +61,15 @@
 	if(p != nil)
 		*p = '.';

-	// try dot, -L "libdir", and then goroot.
-	for(i=0; i<ctxt->nlibdir; i++) {
-		snprint(pname, sizeof pname, "%s/%s", ctxt->libdir[i], name);
-		if(access(pname, AEXIST) >= 0)
-			break;
+	if((!ctxt->windows && name[0] == '/') || (ctxt->windows && name[1] == ':'))
+		snprint(pname, sizeof pname, "%s", name);
+	else {
+		// try dot, -L "libdir", and then goroot.
+		for(i=0; i<ctxt->nlibdir; i++) {
+			snprint(pname, sizeof pname, "%s/%s", ctxt->libdir[i], name);
+			if(access(pname, AEXIST) >= 0)
+				break;
+		}
 	}
 	cleanname(pname);


simple-egl: implement destructors

simple-egl: implement destructors

Destroy all wl objects and call EGL cleanup functions. Reduces leaks
reported by Valgrind considerably, though not to zero.

Signed-off-by: Pekka Paalanen <6c0263d81461c956d504307112a4ce25eaacc3d1@gmail.com>

--- clients/simple-egl.c
+++ clients/simple-egl.c
@@ -66,6 +66,7 @@
 	struct wl_surface *surface;
 	struct wl_shell_surface *shell_surface;
 	EGLSurface egl_surface;
+	struct wl_callback *callback;
 };

 static const char *vert_shader_text =
@@ -123,6 +124,18 @@
 					    EGL_NO_CONTEXT, context_attribs);
 	assert(display->egl.ctx);

+}
+
+static void
+fini_egl(struct display *display)
+{
+	/* Required, otherwise segfault in egl_dri2.c: dri2_make_current()
+	 * on eglReleaseThread(). */
+	eglMakeCurrent(display->egl.dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
+		       EGL_NO_CONTEXT);
+
+	eglTerminate(display->egl.dpy);
+	eglReleaseThread();
 }

 static GLuint
@@ -219,6 +232,18 @@
 	assert(ret == EGL_TRUE);
 }

+static void
+destroy_surface(struct window *window)
+{
+	wl_egl_window_destroy(window->native);
+
+	wl_shell_surface_destroy(window->shell_surface);
+	wl_surface_destroy(window->surface);
+
+	if (window->callback)
+		wl_callback_destroy(window->callback);
+}
+
 static const struct wl_callback_listener frame_listener;

 static void
@@ -276,8 +301,8 @@
 	if (callback)
 		wl_callback_destroy(callback);

-	callback = wl_surface_frame(window->surface);
-	wl_callback_add_listener(callback, &frame_listener, window);
+	window->callback = wl_surface_frame(window->surface);
+	wl_callback_add_listener(window->callback, &frame_listener, window);
 }

 static const struct wl_callback_listener frame_listener = {
@@ -323,9 +348,6 @@
 	struct display display = { 0 };
 	struct window  window  = { 0 };

-	memset(&display, 0, sizeof display);
-	memset(&window,  0, sizeof window);
-
 	window.display = &display;
 	window.geometry.width  = 250;
 	window.geometry.height = 250;
@@ -355,5 +377,16 @@

 	fprintf(stderr, "simple-egl exiting\n");

+	destroy_surface(&window);
+	fini_egl(&display);
+
+	if (display.shell)
+		wl_shell_destroy(display.shell);
+
+	if (display.compositor)
+		wl_compositor_destroy(display.compositor);
+
+	wl_display_destroy(display.display);
+
 	return 0;
 }


Simplified the logic

Simplified the logic

--- src/lio/lio_cp.c
+++ src/lio/lio_cp.c
@@ -93,9 +93,14 @@

   status = op_failure_status;
   q = new_opque();
+  hard_errors = 0;
+  sexp = dexp = NULL;
+  sex = dex = NULL;

   //** Check if the dest exists and if not creates it
   dtype = lioc_exists(cp->dest_tuple.lc, cp->dest_tuple.creds, cp->dest_tuple.path);
+
+log_printf(5, "src=%s dest=%s dtype=%d\n", cp->src_tuple.path, cp->dest_tuple.path, dtype);

   if (dtype == 0) { //** Need to create it
      err = gop_sync_exec(lio_create_object(cp->dest_tuple.lc, cp->dest_tuple.creds, cp->dest_tuple.path, OS_OBJECT_FILE, NULL, NULL));
@@ -130,6 +135,8 @@
   err = opque_waitall(q);
   if (err != OP_STATE_SUCCESS) {
      log_printf(10, "ERROR with os_open src=%s sex=%p dest=%s dex=%p\n", cp->src_tuple.path, sex_data, cp->dest_tuple.path, dex_data);
+     if (sex_data != NULL) free(sex_data);
+     if (dex_data != NULL) free(dex_data);
      goto finished;
   }

@@ -138,16 +145,13 @@
   sex = exnode_create();
   if (exnode_deserialize(sex, sexp, cp->src_tuple.lc->ess) != 0) {
      info_printf(lio_ifd, 0, "ERROR parsing source exnode(%s)!\n", cp->src_tuple.path);
-     exnode_destroy(sex);
-     exnode_exchange_destroy(sexp);
      goto finished;
   }

   sseg = exnode_get_default(sex);
   if (sseg == NULL) {
      info_printf(lio_ifd, 0, "No default segment for source(%s)!\n", cp->src_tuple.path);
-     exnode_destroy(sex);
-     exnode_exchange_destroy(sexp);
+     if (dex_data != NULL) free(dex_data);
      goto finished;
   }

@@ -155,20 +159,12 @@
   dex = exnode_create();
   if (exnode_deserialize(dex, dexp, cp->dest_tuple.lc->ess) != 0) {
      info_printf(lio_ifd, 0, "ERROR parsing destinationexnode(%s)!\n", cp->dest_tuple.path);
-     exnode_destroy(sex);
-     exnode_exchange_destroy(sexp);
-     exnode_destroy(dex);
-     exnode_exchange_destroy(dexp);
      goto finished;
   }

   dseg = exnode_get_default(dex);
   if (dseg == NULL) {
      info_printf(lio_ifd, 0, "No default segment for source(%s)!\n", cp->dest_tuple.path);
-     exnode_destroy(sex);
-     exnode_exchange_destroy(sexp);
-     exnode_destroy(dex);
-     exnode_exchange_destroy(dexp);
      goto finished;
   }

@@ -179,6 +175,7 @@
   if (strcmp(sig1, sig2) == 0) {
      info_printf(lio_ifd, 1, "Cloning %s->%s\n", cp->src_tuple.path, cp->dest_tuple.path);
      gop = segment_clone(sseg, cp->dest_tuple.lc->da, &dseg, CLONE_STRUCT_AND_DATA, NULL, cp->dest_tuple.lc->timeout);
+     log_printf(5, "src=%s  clone gid=%d\n", cp->src_tuple.path, gop_id(gop));
   } else {
      info_printf(lio_ifd, 1, "Slow copy:( %s->%s\n", cp->src_tuple.path, cp->dest_tuple.path);
      type_malloc(buffer, char, bufsize+1);
@@ -210,21 +207,22 @@
   hard_errors = lioc_update_error_counts(cp->src_tuple.lc, cp->src_tuple.creds, cp->src_tuple.path, sseg);
   hard_errors += lioc_update_error_counts(cp->dest_tuple.lc, cp->dest_tuple.creds, cp->dest_tuple.path, dseg);

+finished:
+
   //** Close the files
-  opque_add(q, os_close_object(cp->src_tuple.lc->os, sfd));
-  opque_add(q, os_close_object(cp->dest_tuple.lc->os, dfd));
+  if (sfd != NULL) opque_add(q, os_close_object(cp->src_tuple.lc->os, sfd));
+  if (dfd != NULL) opque_add(q, os_close_object(cp->dest_tuple.lc->os, dfd));
   opque_waitall(q);

   opque_free(q, OP_DESTROY);

-  exnode_destroy(sex);
-  exnode_exchange_destroy(sexp);
-  exnode_destroy(dex);
-  exnode_exchange_destroy(dexp);
+  if (sex != NULL) exnode_destroy(sex);
+  if (sexp != NULL) exnode_exchange_destroy(sexp);
+  if (dex != NULL) exnode_destroy(dex);
+  if (dexp != NULL) exnode_exchange_destroy(dexp);

   if ((hard_errors == 0) && (err == OP_STATE_SUCCESS)) status = op_success_status;

-finished:
   return(status);
 }

@@ -253,6 +251,8 @@
   //** Check if it exists and if not create it
   dtype = lioc_exists(cp->dest_tuple.lc, cp->dest_tuple.creds, cp->dest_tuple.path);

+log_printf(5, "src=%s dest=%s dtype=%d\n", cp->src_tuple.path, cp->dest_tuple.path, dtype);
+
   if (dtype == 0) { //** Need to create it
      err = gop_sync_exec(lio_create_object(cp->dest_tuple.lc, cp->dest_tuple.creds, cp->dest_tuple.path, OS_OBJECT_FILE, NULL, NULL));
      if (err != OP_STATE_SUCCESS) {
@@ -360,6 +360,8 @@

   //** Check if it exists
   ftype = lioc_exists(cp->src_tuple.lc, cp->src_tuple.creds, cp->src_tuple.path);
+
+log_printf(5, "src=%s dest=%s dtype=%d\n", cp->src_tuple.path, cp->dest_tuple.path, ftype);

   if ((ftype & OS_OBJECT_FILE) == 0) { //** Doesn't exist or is a dir
      info_printf(lio_ifd, 1, "ERROR source file(%s) doesn't exist or is a dir ftype=%d!\n", cp->src_tuple.path, ftype);


Added recomendations in SessionSettings documentation

--- src/sessionsettings.h
+++ src/sessionsettings.h
@@ -91,6 +91,10 @@
      * Whether cookies generated by this object should only be used in HTTP
      * requests. It prevents, for example, scripting engines in the user agent
      * from accessing the cookie.
+     *
+     * \note
+     * You should turn this attribute true if you will use this cookie to
+     * store sensitive data.
      */
     bool httpOnly;

@@ -125,6 +129,10 @@
      * This attribute only protects cookie's confidentiality. An active network
      * attacker can overwrite secure cookies from an insecure channel,
      * disrupting their integrity.
+     *
+     * \note
+     * You should turn this attribute true if you will use this cookie to
+     * store sensitive data.
      *
      * \sa
      * HttpsServer


add proto for bcr_ready_add() and spacing

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@12773 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- sliod/bmap_iod.h
+++ sliod/bmap_iod.h
@@ -98,8 +98,8 @@
 	struct srt_bmap_wire	*biod_bmap_wire;
 	struct psclist_head	 biod_lentry;
 	struct timespec		 biod_age;
-	struct psc_lockedlist    biod_bklog_bcrs;
-	lnet_process_id_t        biod_rls_cnp;
+	struct psc_lockedlist	 biod_bklog_bcrs;
+	lnet_process_id_t	 biod_rls_cnp;
 	uint64_t		 biod_bcr_xid;
 	uint64_t		 biod_bcr_xid_last;
 	uint64_t		 biod_cur_seqkey[2];
@@ -107,7 +107,7 @@
 	uint32_t		 biod_crcdrty_slvrs;
 	uint32_t		 biod_inflight;
 	uint32_t		 biod_rlsseq;
-	uint32_t                 biod_bcr_sched;
+	uint32_t		 biod_bcr_sched;
 };

 #define biodi_2_wire(bi)	(bi)->biod_bmap_wire
@@ -121,7 +121,7 @@

 #define bmap_2_crcbits(b, sl)	biodi_2_crcbits(bmap_2_biodi(b), (sl))

-#define BIOD_CRCUP_MAX_AGE	 2		/* in seconds */
+#define BIOD_CRCUP_MAX_AGE	2		/* in seconds */

 static inline int
 bmap_iod_timeo_cmp(const void *x, const void *y)
@@ -145,9 +145,10 @@
 void bcr_hold_2_ready(struct biod_infl_crcs *, struct biod_crcup_ref *);
 void bcr_hold_add(struct biod_infl_crcs *, struct biod_crcup_ref *);
 void bcr_hold_requeue(struct biod_infl_crcs *, struct biod_crcup_ref *);
+void bcr_ready_add(struct biod_infl_crcs *, struct biod_crcup_ref *);
+void bcr_ready_remove(struct biod_infl_crcs *, struct biod_crcup_ref *);
 void bcr_xid_check(struct biod_crcup_ref *);
 void bcr_xid_last_bump(struct biod_crcup_ref *);
-void bcr_ready_remove(struct biod_infl_crcs *, struct biod_crcup_ref *);

 void sliod_bmaprlsthr_spawn(void);


Don't attempt to close file when there is no backing

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@20991 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- sliod/fidc_iod.c
+++ sliod/fidc_iod.c
@@ -205,12 +205,13 @@
 		 * Need to reopen the backing file and possibly remove
 		 * the old one.
 		 */
-		if (close(fcmh_2_fd(f)) == -1)
-			DEBUG_FCMH(PLL_ERROR, f,
-			    "close() failed errno=%d",
-			    errno);
-		else
-			psc_rlim_adj(RLIMIT_NOFILE, -1);
+		if (!(f->fcmh_flags & FCMH_NO_BACKFILE)) {
+			if (close(fcmh_2_fd(f)) == -1)
+				DEBUG_FCMH(PLL_ERROR, f,
+				    "close errno=%d", errno);
+			else
+				psc_rlim_adj(RLIMIT_NOFILE, -1);
+		}

 		oldfg.fg_fid = fcmh_2_fid(f);
 		oldfg.fg_gen = fcmh_2_gen(f);


fix startup order

fix startup order

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@18534 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- sliod/main_iod.c
+++ sliod/main_iod.c
@@ -186,6 +186,8 @@
 	bmap_rls_pool = psc_poolmaster_getmgr(&bmap_rls_poolmaster);

 	sli_repl_init();
+	pscthr_init(SLITHRT_STATFS, 0, slistatfsthr_main, NULL, 0,
+	    "slistatfsthr");

 	prefmds = globalConfig.gconf_prefmds;
 	if (argc)
@@ -203,8 +205,6 @@

 	sli_rpc_initsvc();
 	psc_tiosthr_spawn(SLITHRT_TIOS, "slitiosthr");
-	pscthr_init(SLITHRT_STATFS, 0, slistatfsthr_main, NULL, 0,
-	    "slistatfsthr");
 	slibmaprlsthr_spawn();
 	lc_reginit(&bmapReapQ, struct bmapc_memb, bcm_lentry,
 	    "bmapReapQ");


Add drop_collection and fix count to use db.coll format.

--- src/lua-mongoc.c
+++ src/lua-mongoc.c
@@ -6,6 +6,7 @@
 #include <lua.h>
 #include <lauxlib.h>
 #include <math.h>
+#include <string.h>
 #include "mongo.h"

 #define LUAMONGOC_VERSION 		"lua-mongoc 0.1"
@@ -521,17 +522,48 @@
 	return 1;
 }

+static int lconn_drop_collection(lua_State *L)
+{
+	bson * b = bson_create();
+	mongo * conn = check_connection(L, 1);
+
+	char * s = (char *)luaL_checkstring(L, 2);
+	const char * sep = ".";
+	char * db;
+	char * coll;
+
+	db = strtok(s, sep);
+	coll = strtok(NULL, sep);
+
+	if(mongo_cmd_drop_collection(conn, db, coll, b) != 0)
+	{
+		luaL_checkstack(L, 2, "Not enough stack to push error");
+		lua_pushnil(L);
+		return 1;
+	}
+
+	lua_pushboolean(L, 1);
+	return 1;
+}
+
 static int lconn_count(lua_State *L)
 {
 	bson * b = bson_create();
 	bson_init(b);
 	mongo * conn = check_connection(L, 1);
-	const char * db = luaL_checkstring(L, 2);
-	const char * coll = luaL_checkstring(L, 3);
-
-	if(!lua_isnoneornil(L, 4)) {
-		luaL_checktype(L, 4, 5);
-		lua_to_bson(L, 4, b);
+
+	char * s = (char *)luaL_checkstring(L, 2);
+	const char * sep = ".";
+	char * db;
+	char * coll;
+
+	db = strtok(s, sep);
+	coll = strtok(NULL, sep);
+
+
+	if(!lua_isnoneornil(L, 3)) {
+		luaL_checktype(L, 3, 5);
+		lua_to_bson(L, 3, b);
 	}

 	if(bson_finish(b) != 0)
@@ -682,6 +714,7 @@
 	{ "find", lconn_find },
 	{ "query", lconn_query },
 	{ "find_one", lconn_find_one },
+	{ "drop_collection", lconn_drop_collection },
 	{ "count", lconn_count },
 	{ "update", lconn_update },
 	{ "insert", lconn_insert },


Remove the a previous cgroup

Remove the a previous cgroup

As a previous run may have created a cgroup but died unexpectedly,
the cgroup can be still there when we try to launch the container
again with the same name. This patch removes the directory if it is
present, if this one is not owned by caller or it is in use (that should
not happen), the rmdir will fail with the corresponding errno.

Signed-off-by: Daniel Lezcano <3211518dd4d87cb3f7ee12cb52e14b7fb2bc0446@fr.ibm.com>

--- src/lxc/cgroup.c
+++ src/lxc/cgroup.c
@@ -94,6 +94,17 @@
 	snprintf(oldname, MAXPATHLEN, "%s/%d", cgroup, pid);
 	snprintf(newname, MAXPATHLEN, "%s/%s", cgroup, name);

+	/* there is a previous cgroup, assume it is empty, otherwise
+	 * that fails */
+	if (!access(newname, F_OK)) {
+		ret = rmdir(newname);
+		if (ret) {
+			SYSERROR("failed to remove previous cgroup '%s'",
+				 newname);
+			return ret;
+		}
+	}
+
 	ret = rename(oldname, newname);
 	if (ret)
 		SYSERROR("failed to rename cgroup %s->%s", oldname, newname);


- Ooops! Adding a missing comma (,).

- Ooops! Adding a missing comma (,).

git-svn-id: c1e39603916b71782cde5facdf0b79eff05c1414@11700 54d463be-8e91-2dee-dedb-b68131a5f0ec

--- src/map/battle.c
+++ src/map/battle.c
@@ -3370,7 +3370,7 @@
 	{ "chase_range_rate",                   &battle_config.chase_range_rate,                100,    0,      INT_MAX,        },
 	{ "gtb_sc_immunity",                    &battle_config.gtb_sc_immunity,                 50,     0,      INT_MAX,        },
 	{ "guild_max_castles",                  &battle_config.guild_max_castles,               0,      0,      INT_MAX,        },
-	{ "guild_skill_relog_delay",            &battle_config.guild_skill_relog_delay          0,      0,      1,              },
+	{ "guild_skill_relog_delay",            &battle_config.guild_skill_relog_delay,         0,      0,      1,              },
 	{ "emergency_call",                     &battle_config.emergency_call,                  11,     0,      31,             },
 	{ "atcommand_gm_only",                  &battle_config.atc_gmonly,                      0,      0,      1,              },
 	{ "atcommand_spawn_quantity_limit",     &battle_config.atc_spawn_quantity_limit,        100,    0,      INT_MAX,        },


Fixed getequipcardid name

Fixed getequipcardid name

Signed-off-by: shennetsind <d2875a25db4b1dbc5c3b90f5ac80c894b5d6c5e5@henn.et>

--- src/map/script.c
+++ src/map/script.c
@@ -11598,7 +11598,7 @@
  Useful for such quests as "Sign this refined item with players name" etc
  Hat[0] +4 -> Player's Hat[0] +4
  *------------------------------------------*/
-BUILDIN(getequpcardid)
+BUILDIN(getequipcardid)
 {
 	int i=-1,num,slot;
 	TBL_PC *sd;
@@ -17638,7 +17638,7 @@
 		BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine.
 		BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info
 		BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info
-		BUILDIN_DEF(getequpcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item
+		BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item
 		// [zBuffer] List of mathematics commands --->
 		BUILDIN_DEF(sqrt,"i"),
 		BUILDIN_DEF(pow,"ii"),


- Amended the permanent NPC variable instance system to utilise the same allocated DBMap** (follow-up to r16018)

git-svn-id: c1e39603916b71782cde5facdf0b79eff05c1414@16019 54d463be-8e91-2dee-dedb-b68131a5f0ec

--- src/map/script.c
+++ src/map/script.c
@@ -4469,12 +4469,10 @@
 		if( data_isreference(data) && !data->ref )
 		{
 			const char* name = reference_getname(data);
-			if( name[0] == '.' && name[1] == '@' ) {
+			if( name[0] == '.' ) {
 				data->ref = (struct DBMap**)aCalloc(sizeof(struct DBMap*), 1);
-				data->ref[0] = st->stack->var_function;
+				data->ref[0] = (name[1] == '@' ? st->stack->var_function : st->script->script_vars);
 			}
-			else if( name[0] == '.' )
-				data->ref = &st->script->script_vars;
 		}
 	}


This should finish to fix Status effect chance for renewal and pre-re(bug:8242) Special Thanks to Playtester for all the information

--- src/map/status.c
+++ src/map/status.c
@@ -6378,9 +6378,7 @@
 	case SC_STUN:
 		sc_def = st->vit*100;
 		sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-#ifdef RENEWAL
 		tick_def2 = st->luk*10;
-#endif
 		break;
 	case SC_POISON:
 	case SC_DPOISON:
@@ -6400,24 +6398,29 @@
 #ifdef RENEWAL
 		sc_def = st->int_*100;
 		sc_def2 = (st->vit + st->luk) * 5 + SCDEF_LVL_DIFF(bl, src, 99, 10);
-		tick_def2 = st->luk * 10;
 #else
 		sc_def = st->vit*100;
 		sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
 #endif
+		tick_def2 = st->luk * 10;
 		break;
 	case SC_BLOODING:
 #ifdef RENEWAL
 		sc_def = st->agi*100;
-		tick_def2 = st->luk*10;
 #else
 		sc_def = st->vit*100;
 #endif
 		sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
+		tick_def2 = st->luk*10;
 		break;
 	case SC_SLEEP:
+#ifdef RENEWAL
+		sc_def = st->agi*100;
+		sc_def2 = (st->int_ + st->luk) * 5 + SCDEF_LVL_DIFF(bl, src, 99, 10);
+#else
 		sc_def = st->int_*100;
 		sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(bl, src, 99, 10);
+#endif
 		tick_def2 = st->luk*10;
 		break;
 	case SC_DEEP_SLEEP:
@@ -6431,7 +6434,6 @@
 		sc_def = st->mdef*100;
 #ifndef RENEWAL
 		sc_def2 = st->luk*10;
-		tick_def2 = 0; //No duration reduction
 #endif
 		tick_def = 0; //No duration reduction
 		break;
@@ -6449,11 +6451,6 @@
 		// Special property: immunity when luk is zero
 		if (st->luk == 0)
 			return 0;
-#ifndef RENEWAL
-		// Special property: immunity when luk is greater than level
-		if (st->luk > status->get_lv(bl))
-			return 0;
-#endif
 		sc_def = st->luk*100;
 		sc_def2 = st->luk*10 + SCDEF_LVL_DIFF(NULL, src, 99, 10); // Curse only has a level penalty and no resistance
 		tick_def = st->vit*100;


src/marpaESLIF.c: undef default string representation is empty, \"null\" is reserved to json mode

--- src/marpaESLIF.c
+++ src/marpaESLIF.c
@@ -13606,11 +13606,15 @@
     case MARPAESLIF_VALUE_TYPE_UNDEF:
       /* fprintf(stdout, "UNDEF\n"); fflush(stdout); */
       /* Undef default representation:
-         - string mode: null, json: null
+         - string mode: "", json: "null"
          - binary mode: N/A
       */
       if (contextp->stringb) {
-        GENERICLOGGER_TRACEF(genericLoggerp, "%s", "null");
+        if (contextp->jsonb) {
+          GENERICLOGGER_TRACE(genericLoggerp, "null");
+        } else {
+          GENERICLOGGER_TRACE(genericLoggerp, "");
+        }
       } else {
         continueb = 1;
       }


* Solaris 2.2 port

* Solaris 2.2 port

error: pathspec 'src/md-solaris.h' did not match any file(s) known to git

--- src/md-solaris.h
+++ src/md-solaris.h
@@ -0,0 +1,52 @@
+/*  md-solaris.h,v 1.16 1993/06/28 13:08:52 jan Exp
+
+    Copyright (c) 1990 Jan Wielemaker. All rights reserved.
+    See ../LICENCE to find out about your rights.
+    jan@swi.psy.uva.nl
+
+    Purpose: Machine description for Solaris 2.2 (running on SPARC)
+*/
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+NOTE:	/lri2/jan/{lib,include} hold the GNU readline library.  Modify
+	to fit your system.
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+#define M_CC			gcc
+#define M_OPTIMIZE	        -O2
+#define M_LDFLAGS		-L/lri2/jan/lib
+#define M_CFLAGS		-funsigned-char -I/lri2/jan/include
+#define M_LIBS			-lm -ltermcap -lreadline -lelf
+
+			/* compiler */
+#define solaris			1
+#define SGU			1
+#define ANSI			__GNUC__
+#define O_ULONG_PREDEFINED	1
+
+			/* Operating system */
+#define O_PROFILE		1
+#define O_SIG_AUTO_RESET	1
+#define O_CAN_MAP		1
+#define O_VMCODE_IS_ADDRESS	0
+#define O_NO_SEGV_ADDRESS	1
+#define MAX_VIRTUAL_ADDRESS	(512 * 1024 *1024)
+#define O_FOREIGN		0
+#define O_SAVE			1
+#define O_ELF			1
+#define O_SAVE_STDIO		1
+#define DEFAULT_PATH		":.:/usr/ucb:/bin:/usr/bin:";
+
+			/* terminal driver */
+#define O_READLINE		1
+#define O_TERMIOS 		1
+#define O_FOLD 			0
+
+			/* Interfaces */
+#define O_PCE 			1
+
+#define MACHINE			"sparc"
+#define OPERATING_SYSTEM	"solaris"
+#define MACHINE_ID		"solaris"
+
+#define index(s, c)		strchr(s, c)


mds: drop unused CInode::PIN_PURGING

mds: drop unused CInode::PIN_PURGING

--- src/mds/CInode.h
+++ src/mds/CInode.h
@@ -80,7 +80,7 @@
   static const int PIN_BATCHOPENJOURNAL = 9;
   static const int PIN_SCATTERED =        10;
   static const int PIN_STICKYDIRS =       11;
-  static const int PIN_PURGING =         -12;
+  //static const int PIN_PURGING =         -12;
   static const int PIN_FREEZING =         13;
   static const int PIN_FROZEN =           14;
   static const int PIN_IMPORTINGCAPS =    15;
@@ -101,7 +101,7 @@
     case PIN_BATCHOPENJOURNAL: return "batchopenjournal";
     case PIN_SCATTERED: return "scattered";
     case PIN_STICKYDIRS: return "stickydirs";
-    case PIN_PURGING: return "purging";
+      //case PIN_PURGING: return "purging";
     case PIN_FREEZING: return "freezing";
     case PIN_FROZEN: return "frozen";
     case PIN_IMPORTINGCAPS: return "importingcaps";


Cleaned up memory allocator

Cleaned up memory allocator

--- src/mir_memory.c
+++ src/mir_memory.c
@@ -1,5 +1,6 @@
 #include "mir_memory.h"
 #include "mir_defines.h"
+#include "mir_utils.h"

 #include <stdlib.h>
 #include <stdint.h>
@@ -47,53 +48,39 @@
     mir_page_attr_set(&alloc);
     memptr = tmc_alloc_map(&alloc, bytes_p2);

-    if (memptr != NULL)
-    {
 #ifdef MIR_MEMORY_ALLOCATOR_DEBUG
-        __sync_fetch_and_add(&g_total_allocated_memory, bytes);
+    MIR_ASSERT(memptr != NULL);
+    __sync_fetch_and_add(&g_total_allocated_memory, bytes);
 #endif
-    }
+
     return memptr;
 }/*}}}*/

 void mir_free_int(void *p, size_t bytes)
 {/*{{{*/
-    if(p != NULL && bytes > 0)
-    {
-        unsigned long bytes_p2 = upper_power_of_two((unsigned long) bytes);
+    MIR_ASSERT(p != NULL);
+    MIR_ASSERT(bytes > 0);
+    unsigned long bytes_p2 = upper_power_of_two((unsigned long) bytes);
+    tmc_alloc_unmap(p, bytes_p2);
+    p = NULL;
 #ifdef MIR_MEMORY_ALLOCATOR_DEBUG
-        __sync_fetch_and_sub(&g_total_allocated_memory, bytes);
+    __sync_fetch_and_sub(&g_total_allocated_memory, bytes);
 #endif
-
-        tmc_alloc_unmap(p, bytes_p2);
-    }
 }/*}}}*/

 void mir_page_attr_set(tmc_alloc_t* alloc)
 {/*{{{*/
 #if defined (MIR_PAGE_NO_LOCAL_CACHING)
-tmc_alloc_set_caching(alloc, MAP_CACHE_NO_LOCAL);
+    tmc_alloc_set_caching(alloc, MAP_CACHE_NO_LOCAL);
 #elif defined (MIR_PAGE_NO_L1_CACHING)
-tmc_alloc_set_caching(alloc, MAP_CACHE_NO_L1);
+    tmc_alloc_set_caching(alloc, MAP_CACHE_NO_L1);
 #elif defined (MIR_PAGE_NO_L2_CACHING)
-tmc_alloc_set_caching(alloc, MAP_CACHE_NO_L2);
+    tmc_alloc_set_caching(alloc, MAP_CACHE_NO_L2);
 #endif
 return;
 }/*}}}*/

 #else
-
-/*void* mir_malloc_int(size_t bytes)*/
-/*{[>{{{<]*/
-    /*void* memptr = malloc(bytes);*/
-    /*if (memptr)*/
-    /*{*/
-/*#ifdef MIR_MEMORY_ALLOCATOR_DEBUG*/
-        /*__sync_fetch_and_add(&g_total_allocated_memory, bytes);*/
-/*#endif*/
-    /*}*/
-    /*return memptr;*/
-/*}[>}}}<]*/

 void* mir_malloc_int(size_t bytes)
 {/*{{{*/
@@ -101,28 +88,23 @@
     void* memptr = NULL;
     int rval = posix_memalign(&memptr, MIR_PAGE_ALIGNMENT, bytes_p2);

-    if (rval == 0)
-    {
 #ifdef MIR_MEMORY_ALLOCATOR_DEBUG
-        __sync_fetch_and_add(&g_total_allocated_memory, bytes);
+    MIR_ASSERT(rval == 0);
+    __sync_fetch_and_add(&g_total_allocated_memory, bytes);
 #endif
-    }
+
     return memptr;
 }/*}}}*/

 void mir_free_int(void *p, size_t bytes)
 {/*{{{*/
-    if(p != NULL )
-    {
-        if(bytes > 0)
-        {
+    MIR_ASSERT(p != NULL);
+    MIR_ASSERT(bytes > 0);
+    free(p);
+    p = NULL;
 #ifdef MIR_MEMORY_ALLOCATOR_DEBUG
-            __sync_fetch_and_sub(&g_total_allocated_memory, bytes);
+    __sync_fetch_and_sub(&g_total_allocated_memory, bytes);
 #endif
-        }
-
-        free(p);
-    }
 }/*}}}*/

 #endif


improve error reporting of getFileList

improve error reporting of getFileList

--- src/misc/files.h
+++ src/misc/files.h
@@ -26,6 +26,8 @@
 #include <list>
 #include <string>

+#include "fatal.h"
+
 namespace ydsh {

 inline void getFileList(const char *dirPath, bool recursive, std::vector<std::string> &results) {
@@ -37,7 +39,7 @@
         dirList.pop_front();
         DIR *dir = opendir(path.c_str());
         if(dir == nullptr) {
-            return;
+            fatal("%s: %s\n", path.c_str(), strerror(errno));
         }

         for(dirent *entry; (entry = readdir(dir)) != nullptr;) {


A variable of type hl_entry was being used to copy pointer values of type py_handler. Because of void* casting the code still worked fine, but the mixing of pointer types could make someone looking at the code think input/output filter lists held a data type different to what they actually are.

--- src/mod_python.c
+++ src/mod_python.c
@@ -740,6 +740,7 @@
     char *key;
     apr_ssize_t klen;
     hl_entry *hle;
+    py_handler *fh;

     /* we basically allow the local configuration to override global,
      * by first copying current values and then new values on top
@@ -766,13 +767,13 @@
     }

     for (hi = apr_hash_first(p, cc->in_filters); hi; hi=apr_hash_next(hi)) {
-        apr_hash_this(hi, (const void **)&key, &klen, (void **)&hle);
-        apr_hash_set(merged_conf->in_filters, key, klen, (void *)hle);
+        apr_hash_this(hi, (const void **)&key, &klen, (void **)&fh);
+        apr_hash_set(merged_conf->in_filters, key, klen, (void *)fh);
     }

     for (hi = apr_hash_first(p, cc->out_filters); hi; hi=apr_hash_next(hi)) {
-        apr_hash_this(hi, (const void **)&key, &klen, (void **)&hle);
-        apr_hash_set(merged_conf->out_filters, key, klen, (void *)hle);
+        apr_hash_this(hi, (const void **)&key, &klen, (void **)&fh);
+        apr_hash_set(merged_conf->out_filters, key, klen, (void *)fh);
     }

     /** copy new **/
@@ -788,13 +789,13 @@
     }

     for (hi = apr_hash_first(p, nc->in_filters); hi; hi=apr_hash_next(hi)) {
-        apr_hash_this(hi, (const void**)&key, &klen, (void **)&hle);
-        apr_hash_set(merged_conf->in_filters, key, klen, (void *)hle);
+        apr_hash_this(hi, (const void**)&key, &klen, (void **)&fh);
+        apr_hash_set(merged_conf->in_filters, key, klen, (void *)fh);
     }

     for (hi = apr_hash_first(p, nc->out_filters); hi; hi=apr_hash_next(hi)) {
-        apr_hash_this(hi, (const void**)&key, &klen, (void **)&hle);
-        apr_hash_set(merged_conf->out_filters, key, klen, (void *)hle);
+        apr_hash_this(hi, (const void**)&key, &klen, (void **)&fh);
+        apr_hash_set(merged_conf->out_filters, key, klen, (void *)fh);
     }

     return (void *) merged_conf;


Two new values added to /server-status?auto.  patch from user Terminar.

git-svn-id: e98c317c6679dcf055eb388f05b44c3a6d6b38c6@1621 152afb58-edef-0310-8abb-c4023f1b3aa9

--- src/mod_status.c
+++ src/mod_status.c
@@ -556,6 +556,7 @@
 	buffer *b;
 	double avg;
 	time_t ts;
+	size_t j;

 	b = chunkqueue_get_append_buffer(con->send);

@@ -580,6 +581,21 @@
 	/* output busy servers */
 	BUFFER_APPEND_STRING_CONST(b, "BusyServers: ");
 	buffer_append_long(b, srv->conns->used);
+	BUFFER_APPEND_STRING_CONST(b, "\n");
+
+	/* output traffic */
+	BUFFER_APPEND_STRING_CONST(b, "Traffic: ");
+	avg = p->abs_traffic_out / (srv->cur_ts - srv->startup_ts);
+	buffer_append_long(b, avg);
+	BUFFER_APPEND_STRING_CONST(b, "\n");
+
+	/* output traffic 5s */
+	BUFFER_APPEND_STRING_CONST(b, "Traffic5s: ");
+	for (j = 0, avg = 0; j < 5; j++) {
+		avg += p->mod_5s_traffic_out[j];
+	}
+	avg /= 5;
+	buffer_append_long(b, avg);
 	BUFFER_APPEND_STRING_CONST(b, "\n");

 	/* set text/plain output */


fixed the handling of the global webdav.log-xml option

git-svn-id: 77a2ea9ad361e718a11071bafecd9426888b997a@910 152afb58-edef-0310-8abb-c4023f1b3aa9

--- src/mod_webdav.c
+++ src/mod_webdav.c
@@ -291,6 +291,7 @@

 	PATCH(enabled);
 	PATCH(is_readonly);
+	PATCH(log_xml);

 #ifdef USE_PROPPATCH
 	PATCH(sql);


[mod_webdav] fix file uploads > 128M (fixes #2970)

(thx Gundersanne)

x-ref:
  "mod_webdav writes to fd=-1 when uploading large files (1000M)"
  https://redmine.lighttpd.net/issues/2970

--- src/mod_webdav.c
+++ src/mod_webdav.c
@@ -3325,7 +3325,7 @@
     /*(request body provided in temporary file, so ok to mmap().
      * Otherwise, must check defined(ENABLE_MMAP)) */
     /* chunk_reset() or chunk_free() will clean up mmap'd chunk */
-    /* close c->file.fd only faster mmap() succeeds, since it will not
+    /* close c->file.fd only after mmap() succeeds, since it will not
      * be able to be re-opened if it was a tmpfile that was unlinked */
     /*assert(c->type == FILE_CHUNK);*/
     if (MAP_FAILED != c->file.mmap.start)
@@ -4274,6 +4274,9 @@
     }
     buffer_clear(cq->last->mem); /* file already unlink()ed */
     chunkqueue_set_tempdirs(cq, cq->tempdirs, INTMAX_MAX);
+    /* force huge cq->upload_temp_file_size since chunkqueue_set_tempdirs()
+     * might truncate upload_temp_file_size to chunk.c:MAX_TEMPFILE_SIZE */
+    cq->upload_temp_file_size = INTMAX_MAX;
     cq->last->file.is_temp = 1;

     return HANDLER_GO_ON;


Fix chunk coordinate wraparound after coordinate changes

--- src/narf/world.h
+++ src/narf/world.h
@@ -61,9 +61,9 @@
 		// TODO: verify size is a multiple of chunk_size and a power of 2

 		// world coordinate masks for wraparound
-		// y does not wrap around
+		// z does not wrap around
 		mask_x_ = size_x_ - 1;
-		mask_z_ = size_z_ - 1;
+		mask_y_ = size_y_ - 1;

 		// chunk shifts to get chunk coords from world coords
 		chunk_shift_x_ = ilog2(chunk_size_x);
@@ -188,7 +188,7 @@
 	Chunk **chunks_;

 	uint32_t size_x_, size_y_, size_z_; // size of the world in blocks
-	uint32_t mask_x_, mask_z_;
+	uint32_t mask_x_, mask_y_;

 	uint32_t chunk_size_x_, chunk_size_y_, chunk_size_z_;

@@ -206,12 +206,12 @@
 	{
 		// wrap around
 		x = x & mask_x_;
-		z = z & mask_z_;
-
-		// clamp y to world height
+		y = y & mask_y_;
+
+		// clamp z to world height
 		// TODO
-		if (y >= size_y_) {
-			y = size_y_ - 1;
+		if (z >= size_z_) {
+			z = size_z_ - 1;
 		}

 		*chunk_x = x >> chunk_shift_x_;


Fix setDeferredMultiBulkLength() c->reply_bytes handling with EMBSTR

This function missed proper handling of reply_bytes when gluing to the
previous object was used. The issue was introduced with the EMBSTR new
string object encoding.

This fixes issue #1208.

--- src/networking.c
+++ src/networking.c
@@ -413,7 +413,10 @@
         /* Only glue when the next node is non-NULL (an sds in this case) */
         if (next->ptr != NULL) {
             c->reply_bytes -= zmalloc_size_sds(len->ptr);
-            c->reply_bytes -= zmalloc_size_sds(next->ptr);
+            if (next->encoding == REDIS_ENCODING_RAW)
+                c->reply_bytes -= zmalloc_size_sds(next->ptr);
+            else
+                c->reply_bytes -= sdslen(next->ptr);
             len->ptr = sdscatlen(len->ptr,next->ptr,sdslen(next->ptr));
             c->reply_bytes += zmalloc_size_sds(len->ptr);
             listDelNode(c->reply,ln->next);


list delete: check if list is empty (fixes #21)

Signed-off-by: Alexander Dahl <9b466094ec991a03cb95c489c19c4d75635f0ae5@lespocky.de>

--- src/list.c
+++ src/list.c
@@ -67,6 +67,8 @@
 	// *begin will be used to store the start of the list,
 	// *prior will store the prior item relacted to actual in the loop
 	formvars *begin, *prior;
+
+	if ( !*start ) return 0;

 	// Before of all, is more simple to check if the item
 	// to delete is in the next item. If true, we don't need


[Fix] Redis Server stops accepting connections.

After a client connection fails with error "Accepting client connection: accept:
Unknown error" the server stops accepting new client connections because another
accept isn't queued.

--- src/networking.c
+++ src/networking.c
@@ -33,6 +33,8 @@
 #include "redis.h"
 POSIX_ONLY(#include <sys/uio.h>)
 #include <math.h>
+
+WIN32_ONLY(extern int aeWinQueueAccept(int listenfd);)

 static void setProtocolError(redisClient *c, int pos);

@@ -622,9 +624,16 @@
     while(max--) {
         cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
         if (cfd == ANET_ERR) {
-            if (errno != EWOULDBLOCK)
+            if (errno != EWOULDBLOCK) {
                 redisLog(REDIS_WARNING,
                     "Accepting client connection: %s", server.neterr);
+#ifdef _WIN32
+                if (aeWinQueueAccept(fd) == -1) {
+                    redisLog(REDIS_WARNING,
+                        "acceptTcpHandler: failed to queue another accept.");
+                }
+#endif
+            }
             return;
         }
         redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport);


Fixed return value for string base64/base64url encoding.

--- src/njs_string.c
+++ src/njs_string.c
@@ -317,7 +317,7 @@

     dst.length = njs_base64_encoded_length(src->length);

-    dst.start = njs_string_alloc(vm, &vm->retval, dst.length, dst.length);
+    dst.start = njs_string_alloc(vm, value, dst.length, dst.length);
     if (njs_slow_path(dst.start == NULL)) {
         return NJS_ERROR;
     }
@@ -348,7 +348,7 @@

     dst.length = njs_base64_encoded_length(src->length) - padding;

-    dst.start = njs_string_alloc(vm, &vm->retval, dst.length, dst.length);
+    dst.start = njs_string_alloc(vm, value, dst.length, dst.length);
     if (njs_slow_path(dst.start == NULL)) {
         return NJS_ERROR;
     }


Don't call mosquitto_time() for every client.

--- src/loop.c
+++ src/loop.c
@@ -73,6 +73,7 @@
 	time_t last_backup = mosquitto_time();
 	time_t last_store_clean = mosquitto_time();
 	time_t now;
+	int time_count;
 	int fdcount;
 #ifndef WIN32
 	sigset_t sigblock, origsig;
@@ -114,8 +115,15 @@
 			pollfd_index++;
 		}

+		time_count = 0;
 		for(i=0; i<db->context_count; i++){
 			if(db->contexts[i]){
+				if(time_count > 0){
+					time_count--;
+				}else{
+					time_count = 1000;
+					now = mosquitto_time();
+				}
 				db->contexts[i]->pollfd_index = -1;

 				if(db->contexts[i]->sock != INVALID_SOCKET){
@@ -124,7 +132,7 @@
 						_mosquitto_check_keepalive(db->contexts[i]);
 						if(db->contexts[i]->bridge->round_robin == false
 								&& db->contexts[i]->bridge->cur_address != 0
-								&& mosquitto_time() > db->contexts[i]->bridge->primary_retry){
+								&& now > db->contexts[i]->bridge->primary_retry){

 							if(_mosquitto_try_connect(db->contexts[i]->bridge->addresses[0].address, db->contexts[i]->bridge->addresses[0].port, &bridge_sock, NULL) == MOSQ_ERR_SUCCESS){
 								COMPAT_CLOSE(bridge_sock);
@@ -138,7 +146,7 @@
 					/* Local bridges never time out in this fashion. */
 					if(!(db->contexts[i]->keepalive)
 							|| db->contexts[i]->bridge
-							|| mosquitto_time() - db->contexts[i]->last_msg_in < (time_t)(db->contexts[i]->keepalive)*3/2){
+							|| now - db->contexts[i]->last_msg_in < (time_t)(db->contexts[i]->keepalive)*3/2){

 						if(mqtt3_db_message_write(db->contexts[i]) == MOSQ_ERR_SUCCESS){
 							pollfds[pollfd_index].fd = db->contexts[i]->sock;
@@ -164,19 +172,18 @@
 					if(db->contexts[i]->bridge){
 						/* Want to try to restart the bridge connection */
 						if(!db->contexts[i]->bridge->restart_t){
-							db->contexts[i]->bridge->restart_t = mosquitto_time()+db->contexts[i]->bridge->restart_timeout;
+							db->contexts[i]->bridge->restart_t = now+db->contexts[i]->bridge->restart_timeout;
 							db->contexts[i]->bridge->cur_address++;
 							if(db->contexts[i]->bridge->cur_address == db->contexts[i]->bridge->address_count){
 								db->contexts[i]->bridge->cur_address = 0;
 							}
 							if(db->contexts[i]->bridge->round_robin == false && db->contexts[i]->bridge->cur_address != 0){
-								db->contexts[i]->bridge->primary_retry = mosquitto_time() + 5;
+								db->contexts[i]->bridge->primary_retry = now + 5;
 							}
 						}else{
 							if(db->contexts[i]->bridge->start_type == bst_lazy && db->contexts[i]->bridge->lazy_reconnect){
 								mqtt3_bridge_connect(db, db->contexts[i]);
 							}
-							now = mosquitto_time();
 							if(db->contexts[i]->bridge->start_type == bst_automatic && now > db->contexts[i]->bridge->restart_t){
 								db->contexts[i]->bridge->restart_t = 0;
 								if(mqtt3_bridge_connect(db, db->contexts[i]) == MOSQ_ERR_SUCCESS){
@@ -205,7 +212,7 @@
 							 * persistent_client_expiration seconds ago. If so,
 							 * expire it and clean up.
 							 */
-							if(mosquitto_time() > db->contexts[i]->disconnect_t+db->config->persistent_client_expiration){
+							if(now > db->contexts[i]->disconnect_t+db->config->persistent_client_expiration){
 								_mosquitto_log_printf(NULL, MOSQ_LOG_NOTICE, "Expiring persistent client %s due to timeout.", db->contexts[i]->id);
 #ifdef WITH_SYS_TREE
 								g_clients_expired++;
@@ -243,7 +250,6 @@
 				}
 			}
 		}
-		now = mosquitto_time();
 #ifdef WITH_PERSISTENCE
 		if(db->config->persistence && db->config->autosave_interval){
 			if(db->config->autosave_on_changes){
@@ -252,14 +258,14 @@
 					db->persistence_changes = 0;
 				}
 			}else{
-				if(last_backup + db->config->autosave_interval < now){
+				if(last_backup + db->config->autosave_interval < mosquitto_time()){
 					mqtt3_db_backup(db, false, false);
 					last_backup = mosquitto_time();
 				}
 			}
 		}
 #endif
-		if(!db->config->store_clean_interval || last_store_clean + db->config->store_clean_interval < now){
+		if(!db->config->store_clean_interval || last_store_clean + db->config->store_clean_interval < mosquitto_time()){
 			mqtt3_db_store_clean(db);
 			last_store_clean = mosquitto_time();
 		}


Version 0.1.5

Version 0.1.5

--- src/love.c
+++ src/love.c
@@ -7,7 +7,7 @@

 #include "luaobj.h"

-#define LOVE_VERSION "0.1.4"
+#define LOVE_VERSION "0.1.5"

 int l_love_getVersion(lua_State *L) {


added TODO

added TODO


add test open file if alreday exit

add test open file if alreday exit

--- src/main.c
+++ src/main.c
@@ -5,6 +5,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/mman.h>
+#include <sys/types.h>
 #include "utils.h"
 #include "mdazibao.h"
 #include "main.h"
@@ -481,6 +482,7 @@
 int cmd_extract(int argc , char **argv, char *dz_path) {
         dz_t dz;
         tlv_t tlv;
+        int flag_exist = -1;
         long off;
         int fd, real_size;
         char *data;
@@ -495,13 +497,15 @@
          * must be wrong.
          */
         if (argv[0][0] < 48 || argv[0][0] > 57) {
-                fprintf(stderr, "Usage:\n    rm <offset> <dazibao>\n");
+                fprintf(stderr,
+                        "Usage:\n       extract <offset> <file> <dazibao>\n");
                 return DZ_ARGS_ERROR;
         }

-        off = str2dec_positive(argv[argc - 1]);
+        off = str2dec_positive(argv[0]);

         if (off < DAZIBAO_HEADER_SIZE) {
+                printf("%d\n",(int) off);
                 fprintf(stderr, "wrong offset\n");
                 return DZ_OFFSET_ERROR;
         }
@@ -518,13 +522,14 @@
         }

         path = argv[1];
-        if (access(path,F_OK) < 0) {
-                printf("file %s already exist\n",path);
-                dz_close(&dz);
-                return -1;
-        }
-
-        fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0644);
+        if (access(path,F_OK) == 0) {
+                flag_exist = 0;
+                fd = open(path, O_RDWR);
+                printf("if %d\n",fd);
+        } else {
+                fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0644);
+                printf("%d\n",fd);
+        }

         if (fd == -1) {
                 dz_close(&dz);
@@ -537,27 +542,35 @@
                 return -1;
         }

+        if (dz_tlv_at(&dz, &tlv, off) < 0) {
+                printf("error to read type and length tlv\n");
+                dz_close(&dz);
+                return -1;
+        }
+
         if (dz_read_tlv(&dz, &tlv, off) < 0) {
-                printf("error to read tlv\n");
+                printf("error to read value tlv\n");
                 dz_close(&dz);
                 return -1;
         }

-        /*TODO:
-                write value from tlv of path
-                use mmap not write
-        */
         real_size = tlv_get_length(&tlv);
+        printf("type %d\n", tlv_get_type(&tlv));
+        printf("length %d\n", real_size);
         data = (char*)mmap(NULL, real_size, PROT_WRITE, MAP_SHARED, fd, 0);
-        memcpy(data,tlv_get_value_ptr(&tlv),real_size);
+        memcpy(data, tlv_get_value_ptr(&tlv), real_size);
         tlv_destroy(&tlv);
-        /*
-        if (dz_rm_tlv(&daz_buf, (off_t)off)) {
-                fprintf(stderr, "rm failed\n");
-                dz_close(&daz_buf);
-                return -1;
-        }
-        */
+
+        if (flag_exist == 0 ) {
+                if (ftruncate(fd, real_size) < 0) {
+                        fprintf(stderr, "Error while ftruncate pathn");
+                        dz_close(&dz);
+                        close(fd);
+                        return -1;
+                }
+        }
+        close(fd);
+
         if (dz_close(&dz) < 0) {
                 fprintf(stderr, "Error while closing the dazibao\n");
                 return -1;


Windows: Preliminary solution for multiline input fields

--- src/main.c
+++ src/main.c
@@ -1904,21 +1904,26 @@
 		} else if (options[i].type == CONFIG_TYPE_BOOLEAN) {
 			cl = 0x80;
 			style |= BS_AUTOCHECKBOX;
-		} else if ((options[i].type == CONFIG_TYPE_FILE)
-		           || (options[i].type == CONFIG_TYPE_DIRECTORY)) {
+		}
+		else if ((options[i].type == CONFIG_TYPE_FILE)
+			|| (options[i].type == CONFIG_TYPE_DIRECTORY)) {
 			style |= WS_BORDER | ES_AUTOHSCROLL;
 			width -= 20;
 			cl = 0x81;
 			add_control(&p,
-			            dia,
-			            0x80,
-			            ID_CONTROLS + i + ID_FILE_BUTTONS_DELTA,
-			            WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
-			            x + width + LABEL_WIDTH + 5,
-			            y,
-			            15,
-			            12,
-			            "...");
+				dia,
+				0x80,
+				ID_CONTROLS + i + ID_FILE_BUTTONS_DELTA,
+				WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
+				x + width + LABEL_WIDTH + 5,
+				y,
+				15,
+				12,
+				"...");
+		} else if (options[i].type == CONFIG_TYPE_STRING_MULTILINE) {
+			/* TODO: This is not really uer friendly */
+			cl = 0x81;
+			style |= WS_BORDER | ES_AUTOHSCROLL | ES_MULTILINE | ES_WANTRETURN | ES_AUTOVSCROLL;
 		} else {
 			cl = 0x81;
 			style |= WS_BORDER | ES_AUTOHSCROLL;


Fix flops that prevent compiling on avr-gcc 7.2.0

--- src/main.c
+++ src/main.c
@@ -60,17 +60,17 @@
 	POWER_PORT &= ~_BV(POWER_PIN);
 }

-inline static ledToggle() {
+inline static void ledToggle() {
     LED_PORT ^= _BV(LED_A);
 }

-static inline void adcSetup() {
+inline static void adcSetup() {
     ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
     ADCSRA |= _BV(ADIE);
     ADMUXB = 0;
 }

-void inline sleepWhileADC() {
+inline static void sleepWhileADC() {
     set_sleep_mode(SLEEP_MODE_ADC);
     sleep_mode();
 }
@@ -118,7 +118,7 @@

 #define PCINT1 1

-static inline stopLightMeaseurement() {
+static inline void stopLightMeasurement() {
     GIMSK &= ~_BV(PCIE0);
     TCCR1B = 0;
     PCMSK0 &= ~_BV(PCINT1);
@@ -132,12 +132,12 @@
     TCCR1B = 0;          //stop timer
     lightCounter = TCNT1;

-    stopLightMeaseurement();
+    stopLightMeasurement();
 }

 ISR(TIMER1_OVF_vect) {
     lightCounter = 65535;
-    stopLightMeaseurement();
+    stopLightMeasurement();
 }

 static inline uint16_t getLight() {
@@ -189,7 +189,7 @@
 uint16_t currCapacitance = 0;
 int temperature = 0;

-static inline loopSensorMode() {
+static inline void loopSensorMode() {
     while(1) {
         if(twiDataInReceiveBuffer()) {
             uint8_t usiRx = twiReceiveByte();


make feh --list work without X.

make feh --list work without X.

feh -O should also be able to run without it, but that requires slightly more work.
I'll fix that one later, I guess.

<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=373209>

--- src/main.c
+++ src/main.c
@@ -44,7 +44,8 @@

    init_parse_options(argc, argv);

-   init_x_and_imlib();
+   if (!opt.list)
+      init_x_and_imlib();

    feh_event_init();


Fix consecutive BBIO

Fix consecutive BBIO

--- src/main.c
+++ src/main.c
@@ -89,6 +89,7 @@
 		case 0:
 			if (++i == 20) {
 				cmd_bbio(con);
+				i=0;
 			}
 			break;
 		/* SUMP identification is 5*\x00 \x02 */