increments are tried). Fixes looping from bug #27555.
        ssrc = edg_wll_SourceToString(e->any.source);
 
 /* try to insert (someone else may be doing the same) */
-       while (1) {
+       {
                char    *max = NULL;
 
                if (edg_wll_ExecStmt(ctx,select_max,&sh) < 0 ||
                edg_wll_FreeStmt(&sh); 
                
                next = max && *max ? atoi(max)+1 : 0;
+               free(max);
+       }
                
+       while (1) {
        /* 
         * 1) when using transactions:
         *   Store the whole event right now.
                } else break; /* successful insert */
 
        /* we were late -- try once again */
+               next++;
                free(stmt);
-               free(max);
        }
 
        free(stmt); stmt = NULL;